0

This is the message I get within the document.write output ("document.write(bodytype);")

[objectHTMLSelectElement]

This is my attempt to get a value from the dropdownbox;

var bodytype=document.getElementById("bodytype");
document.getElementById("bodytype").value=bodytype.options[bodytype.selectedIndex].text;

This is the dropdown box code that it's meant to come from;

<select id="bodytype" name="bodytype">
<option>fat</option>
<option>lean</option>
<option>slender</option>
<option>short</option>
<option>tall</option>
</select>

It's printing what it is to the screen rather than the text... am I just missing "" somewhere?

2
Contributors
1
Reply
9
Views
4 Years
Discussion Span
Last Post by IIM
1

Are you saying you want to send some other value on select of drop down.Instead of text use value.

var bodytype=document.getElementById("bodytype");
alert(bodytype.options[bodytype.selectedIndex].text);
alert(bodytype.options[bodytype.selectedIndex].value);
document.getElementById("bodytype").value=bodytype.options[bodytype.selectedIndex].text;

Your html

<select id="bodytype" name="bodytype">
<option value="F">fat</option>
<option value="L">lean</option>
<option value="SL">slender</option>
<option value="S">short</option>
<option value="T">tall</option>
</select>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.