Click to See Complete Forum and Search --> : need a javascript expert
mikel
11-25-2002, 02:17 PM
I need a javascript that will help me add a line of text into a textarea field in a form via a checkbox
I.E WHEN THE CHECKBOX IS CLICKED
THE LINE '\image{my photo}' is added to the <textarea>\image{my photo}</textarea> field
I hope I explained this right .:confused:
kateyez44
11-25-2002, 02:55 PM
but this is what it sounds like you want to do to me. What I would do is create a function to add the line of text to the textarea first. Then, when you create your checkbox, call the function you created from the checkbox's ONCLICK event:
<SCRIPT LANGUAGE = "JavaScript" TYPE = "text/javascript">
<!--
function AddText()
{
var objForm = document.frmTest;
objForm.txtTextArea.Value = "Whatever you want it to say";
}
-->
</SCRIPT>
<INPUT TYPE = CHECKBOX NAME = chkTest VALUE = "Y" ONCLICK = "AddText()">
Hope this helps. Good luck!
mikel
11-25-2002, 08:52 PM
nevermind Its not going to work on my forum script because the textarea already has a set name="message" value and cannot be removed or the board will break... thanks anyways.
==================================
Or is it possible to still get it to work even if the textarea field already has a set name="message" value?
Zach Elfers
11-25-2002, 09:37 PM
<form>
<input type="checkbox" onClick="form.textArea.value='\image{my photo}';"> <input type="checkbox" onClick="form.textArea.value='';">
<textarea name="textArea" cols="65" rows="10"></textarea>
</form>
That should do what you want it to. Hope this helps!:)
mikel
11-25-2002, 10:20 PM
ok I finally got it to work by adding the following line of code to the board software from the last poster
<input type="checkbox" onClick="form.message.value='\\image{my photo}';">
I changed the onclick from "textarea" to "message"
to make my script happy so it wouldnt break the board script
also because of the strange code of the forum software I had to add an extra \ in the onclick="form.message.value='\image{my photo}';"> code as you can see above.:D
Thanx Zach Elfers I will put a credit up to you for helping me
at the board if you give me the ok.
my forum board http://cgi-help.sytes.net