Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating TextArea with dropdown labels when changed 2

Status
Not open for further replies.

Rieekan

Programmer
Apr 2, 2001
737
US
I have the following code, which I thought would update a textarea with comments when the status dropdown changes, but I cannot get it to work. (This is why I'm a server side programmer). Could someone take a look and see where I'm screwing up?

Code:
<html>
<head>
<script language="javascript">
function StatusComment() {
	var list = document.forms[0].status;
	if ( ! list.options ) return;
	var field = document.getElementById('comments');
	var result = list.options[list.selectedIndex].value;
	field.value = 'Status updated to '. result;
}
</script>
</head>
<body>
<form>
<select name="status" onChange="StatusComment();">
<option value="1" selected>Submitted</option>
<option value="2">Being Researched</option>
<option value="3">Inventoried</option>
<option value="4">Implemented</option>
</select>
<textarea name="comments"></textarea>
</form>
</body>
</html>

Thanks in advance,

- Rieekan
 
Make the following changes:
Code:
<html>
<head>
<script language="javascript">
function StatusComment() {
    var list = document.forms[0].elements["status"];
    if ( ! list.options ) return;
    var field = document.forms[0].elements["comments"];
    var result = list.options[list.selectedIndex].value;
    field.value = 'Status updated to ' + result;
}
</script>
</head>
<body>
<form>
<select name="status" onChange="StatusComment();">
<option value="1" selected>Submitted</option>
<option value="2">Being Researched</option>
<option value="3">Inventoried</option>
<option value="4">Implemented</option>
</select>
<textarea name="comments"></textarea>
</form>
</body>
</html>

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
[banghead]
 
Thanks. While that works, it still shows the values. Is there any way to make this show the description of those options instead?

- Rieekan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top