Click to See Complete Forum and Search --> : Website
funnyrunnybunny
07-30-2003, 02:36 PM
Ok i'm planning to make a page on my website. And what i want to do is be able to click on numerous links on a page and have certain words appear in a text box when certain links are clicked. So can anyone tell me how to do that?:confused:
Thank you so much:D
ĪvĪ_bunnie_ĪvĪ
Charles
07-30-2003, 02:51 PM
This will fail for an awful lot of users, but that's what you get with JavaScript. So this is just for demonstration purposes. In the real world you would have to find a way to keep the page working for everybody.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<ol>
<li onclick="document.getElementById('foo').value = this.firstChild.data">Fee</li>
<li onclick="document.getElementById('foo').value = this.firstChild.data">Fie</li>
<li onclick="document.getElementById('foo').value = this.firstChild.data">Foe</li>
<li onclick="document.getElementById('foo').value = this.firstChild.data">Fum</li>
</ol>
<textarea name="foo"></textarea>
Depending on what exactly you need to do, serverside programming might get you there, thus avoiding the problem that Charles mentioned of keeping the page working for those without javascript enabled.
Jupac
07-30-2003, 08:17 PM
Do u want something like this
<html>
<head>
<script>
var a=("texthere")
var b=("texthere1")
var c=("texthere2")
var cc=("")
</script>
</head>
<body>
<table>
<tr bgcolor=#000000>
<font size=2 color=#cc0000>Please select one</font>
<form name="form1">
<textarea name="box1" style=" font-size: 12px; color: red; background-color: #000000;"></textarea>
<div><a href="#" onclick="document.form1.box1.value=a">Select1</a></div>
<div><a href="#" onclick="document.form1.box1.value=b">Select2</a></div>
<div><a href="#" onclick="document.form1.box1.value=c">Select3</a></div>
<div><a href="#" onclick="document.form1.box1.value=cc">Clear</a></div>
</form>
</tr>
</table>
</body>
</html>
That looks very close to what Charles posted, with the exception that your's has many errors, including not specifing the script type, using tables for layout, and using depreciated HTML tags...
funnyrunnybunny
07-31-2003, 10:52 AM
Hey
That stuff is really close to what i wanted. Except i wanted to have numerous words be able to show up in the box. But if you guys dont know how to do that, then i'll improvise and figure out a way to make something work.
Thanks!
ĪvĪ_bunnie_ĪvĪ
Based off Charles solution, you need to use += rather than =
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<ol>
<li onclick="document.getElementById('foo').value += this.firstChild.data">Fee</li>
<li onclick="document.getElementById('foo').value += this.firstChild.data">Fie</li>
<li onclick="document.getElementById('foo').value += this.firstChild.data">Foe</li>
<li onclick="document.getElementById('foo').value += this.firstChild.data">Fum</li>
</ol>
<textarea name="foo"></textarea>
funnyrunnybunny
07-31-2003, 04:17 PM
Thats awesome! thatnks so much! just what i needed!
ĪvĪ_bunnie_ĪvĪ