Reputation: 23
I can't seem to figure this out. I am getting an undefined
instead of philadelphia
output on this script.
<center>
<form NAME="logform">
<select SIZE="1" NAME="store">
<option name='Philadelphia' id ='Joe Smith' value='[email protected]'>Philadelphia</option>
</select>
<br><br>
<input LANGUAGE="JavaScript" TYPE="button" VALUE="Send email"
ONCLICK="location.href = "mailto:" +
document.logform.store.options
[document.logform.store.selectedIndex].
value + "?subject=I would like to buy the " +
document.logform.store.options
[document.logform.store.selectedIndex].
name + " location ""
NAME="Send email">
</form>
</center>
Thanks for the help.
Upvotes: 1
Views: 107
Reputation: 15481
Instead of:
document.logform.store.options[document.logform.store.selectedIndex].name
Use:
document.logform.store.options[document.logform.store.selectedIndex].text
Notice that just .name
at the end was replaced by .text
.
Working Code Snippet:
<center>
<form NAME="logform">
<select SIZE="1" NAME="store">
<option name='Philadelphia' id ='Joe Smith' value='[email protected]'>Philadelphia</option>
</select>
<br><br>
<input LANGUAGE="JavaScript" TYPE="button" VALUE="Send email"
ONCLICK="location.href = "mailto:" +
document.logform.store.options
[document.logform.store.selectedIndex].
value + "?subject=I would like to buy the " +
document.logform.store.options[document.logform.store.selectedIndex].text + " location ""
NAME="Send email">
</form>
</center>
Upvotes: 1