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

09-07-2006, 05: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"";
<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>
Chosen course: <input type="text" size="30" value="<script type='text/javascript'> write('title'); </script>">

09-07-2006, 09: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;


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