Click to See Complete Forum and Search --> : Entering text into textfield
MacMyDay
08-02-2003, 05:10 AM
I'm all new to JavaScript so, in all honestly, haven't a clue. I need it so that when someone clicks on some text it enters it into a text field. The best I've found so far is this
<html>
<head>
<title>JavaScript Sample</title>
</head>
<body>
<form name="ThisForm">
<p><input type="text" id="Textie" name="Textie"></input>
<input type="button" value="Add" onclick="document.ThisForm.Boxie.value = document.ThisForm.Boxie.value + '' + document.ThisForm.Textie.value;return true;"></p>
<p><textarea rows="10" cols="30" name="Boxie" id="Boxie"></textarea></p>
</form>
</body>
</html>
Yet you have to click on the Add button to add it. Is there a way you can modify this so they just click on the text and it adds it?
Thanks
I'm not completely sure what you want, but...
<html>
<head>
<title>JavaScript Sample</title>
</head>
<body>
<form name="ThisForm">
<p><input type="text" id="Textie" name="Textie" onclick="document.ThisForm.Boxie.value = document.ThisForm.Boxie.value + '' + document.ThisForm.Textie.value; return true;">
</p>
<p><textarea rows="10" cols="30" name="Boxie" id="Boxie"></textarea></p>
</form>
</body>
</html>
[J]ona
MacMyDay
08-02-2003, 12:39 PM
Basically it works like the smilies. You click on them and they appear in the text box. But, I need this with text instead of images. I'm gonna have my contacts and when you click on their name it puts their name into the To field. Hope that makes more sense.
It does make more sense, but do you need more help?
[J]ona
MacMyDay
08-02-2003, 01:02 PM
Please. The script you gave me just has two text boxes, unless I'm missing out on something.
Do you mean this:
<html>
<head>
<title>JavaScript Sample</title>
</head>
<body>
<form name="ThisForm">
<p><a href="#" onclick="document.ThisForm.Boxie.value = document.ThisForm.Boxie.value + this.id+', '; return true;" id="Tom">Tom</a></p>
<p><a href="#" onclick="document.ThisForm.Boxie.value = document.ThisForm.Boxie.value + this.id+', '; return true;" id="Dick">Dick</a></p>
<p><a href="#" onclick="document.ThisForm.Boxie.value = document.ThisForm.Boxie.value + this.id+', '; return true;" id="Harry">Harry</a></p>
<p><textarea rows="10" cols="30" name="Boxie" id="Boxie"></textarea></p>
</form>
</body>
</html>
Zero-x252
08-02-2003, 01:28 PM
ALL RIGHT! I HAVE A VERY SIMPLE SOLUTION
<html>
<head>
<title>JavaScript test</title>
</head>
<body>
<span onClick="document.the_form.the_input.value='harry!'">TEXT TO CLICK HERE</span>
<form name="the_form">
<input type="textbox" name="the_input">
</form>
</body>
</html>
THERE!
MacMyDay
08-04-2003, 04:58 AM
Perfect! Thanks a lot.