Page 1 of 1
html tag buttons
Posted: Sun Oct 17, 2004 6:42 am
by andylyon87
How do I go about creating the buttons on forms that allow the user to click them and insert html tags into the textarea box.
Say <B> </B>
or <BR>
like te ones on the forms for posting, I understand it is jscript if someone knows of somewhere there is a tutorial or a good description or someone can just describe it to me, I am having difficulty finding anything about it.
thanks
andylyon87

Posted: Sun Oct 17, 2004 7:43 am
by kettle_drum
You use a bit of javascript.
Code: Select all
function addTag(tag, field){
window.document.<name of form>.field.value = window.document.<name of form>.field.value + tag
}
And then have onClick in the button:
Code: Select all
<input type="button" value="Click Me" onClick="addTag('їb]', some_field)"
Posted: Sun Oct 17, 2004 11:21 am
by andylyon87
would this insert one tag per button say
button 1:<B>
button 2:</B>
or could you have
button 1: <B> +text+ </B>
and if so how would you do the latter
Posted: Sun Oct 17, 2004 3:06 pm
by mudkicker
you can do it by using onDoubleclick() i think.
Posted: Sun Oct 17, 2004 3:40 pm
by feyd
to insert text around a selection you need to work with the selection objects.
http://www.quirksmode.org/js/selected.html
Posted: Mon Oct 18, 2004 11:06 am
by andylyon87
I cant get the first solution to work as i am unsure as to what to put in the field name.
Also i am unsure of how to use the solution provided by feyd to produce something to add tags I understand it gets selected text which could then have tags added to it but I am a rubbish jscrtipter and am more of a beginner in this so have no idea of how to go about this.