View Full Version : Textbox question! please help!
07-14-2003, 11:31 AM
I was woundering how i could get it so if a user presses a button it adds text to the textbox. For example, my game has a chatroom and I want to add bold, italic, underline images so when they click on them it adds "[B],[I] or [U]" to the textbox.
Know what i mean?
07-14-2003, 01:02 PM
You mean exactly the same as on vb Code for these forums? Well, a simple "view source" on the "Post a reply" page indicates that the "B" button is calling:
which, for my guess is in either vbcode_language.js or vbcode.js - which both get included a few lines above it. Download 'em, have a look.
... or you want to know how can this be done in Java Script?
07-22-2003, 02:12 AM
Thanks for the try though spud.
PS: (somthing that works exactly like clicking the smilies when posting in the forum, and it inserts the code in the textbox)
any help appreciated :)
07-22-2003, 02:29 AM
Pretty simple actually, just altering the value property of the input or textarea elements.
Here's an example script I just put together.
document.f.t.value += "[.b]" + window.prompt('Enter the text you want to be bold:','') + "[./b]";
document.f.t.value += "[.i]" + window.prompt('Enter the text you want to be italic:','') + "[./i]";
document.f.t.value += "[.u]" + window.prompt('Enter the text you want to be underlined:','') + "[./u]";
<form name = "f">
<input type = "button" value = "Bold" onclick = "add('b');" />
<input type = "button" value = "Italic" onclick = "add('i');" />
<input type = "button" value = "Underlined" onclick = "add('u');" />
<textarea rows = "10" cols = "50" name = "t"></textarea>
Note: I put periods inside the "tags" so the vB code wouldn't kick in. Remove those and it should work nicely.
07-22-2003, 03:48 AM
Thanks a lot, okay a few more questions if you dont mind me asking...
When pressing the Bold button, it starts the message box with...
"Script Prompt:" is there a way to change this caption?
Could we also do this to the caption of the messagebox itself?
That would be great, also, If i wanted to without a message box, how would i go about that?
07-22-2003, 03:52 AM
If you decide you want this, I could write the script for you and upload it.:D
07-22-2003, 03:55 AM
Could you possibly contact me at e-mail deleted? I would like to show you what im doing, so possibly you could have the best insight on what the best possible options are available to me...
Else, if not possible, I would like to know also, how to insert the text without the command promt as well... (i will use the message boxes for Italic, underline, and bold, but not for smilies)
07-22-2003, 03:57 AM
Alright, I emailed you.
07-22-2003, 04:27 AM
Okay not sure if you got my mail, but...
When pressing cancel, it will display this in the textbox...
Is there a way to prevent this?