...

View Full Version : Wanting to "Write" <Select> box chosen value



h8ids
09-07-2006, 06:54 PM
I have dynamic data being loaded into a select box.
Trying to capture the user's selected option "value" and then "write" the value into a field for editing.

Problem one: option isn't captured by title variable. (Source code proof)
Problem two: input box value = "<script type='text/javascript'> write('title'); </script>"



<script type="text/javascript">
function choice(){
var title = document.courses.value"";
}
</script>
<select name="courses" id="courses" onchange="choice()">
<option value="Please Choose One">Please Choose One</option>n/
<option value="Bible">Bible</option>n/
<option value="Christian Ethics">Christian Ethics</option>n/
<option value="Church History">Church History</option>n/
<option value="Homiletics">Homiletics</option>
</select>
<br>
Chosen course: <input type="text" size="30" value="<script type='text/javascript'> write('title'); </script>">

A1ien51
09-07-2006, 10:29 PM
well you have "" in there for some reason na dyou are reference the form field wrong.

correct way to reference a value in a dropdown list is



var sel = document.forms[0].selectName;
var selValue = sel.options[sel.selectedIndex].value;


Eric

h8ids
09-07-2006, 10:58 PM
Got it now. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum