为什么我的输出未定义

Why is my output undefined

本文关键字:未定义 输出 我的 为什么      更新时间:2023-09-26

我似乎想不通。我在这个脚本上得到的是undefined而不是philadelphia输出。

<center>
<form NAME="logform">
<select SIZE="1" NAME="store">
<option name='Philadelphia' id ='Joe Smith' value='philly@store.com'>Philadelphia</option>
</select>
<br><br>
<input LANGUAGE="JavaScript" TYPE="button" VALUE="Send email"
ONCLICK="location.href = &quot;mailto:&quot; +
document.logform.store.options
[document.logform.store.selectedIndex].
value + &quot;?subject=I would like to buy the &quot; +
document.logform.store.options
[document.logform.store.selectedIndex].
name + &quot; location &quot;"
NAME="Send email">
</form>
</center>

谢谢你的帮助。

代替:

document.logform.store.options[document.logform.store.selectedIndex].name

用途:

document.logform.store.options[document.logform.store.selectedIndex].text

请注意,最后只有.name.text替换。

工作代码段:

<center>
<form NAME="logform">
<select SIZE="1" NAME="store">
<option name='Philadelphia' id ='Joe Smith' value='philly@store.com'>Philadelphia</option>
</select>
<br><br>
<input LANGUAGE="JavaScript" TYPE="button" VALUE="Send email"
ONCLICK="location.href = &quot;mailto:&quot; +
document.logform.store.options
[document.logform.store.selectedIndex].
value + &quot;?subject=I would like to buy the &quot; +
document.logform.store.options[document.logform.store.selectedIndex].text + &quot; location &quot;"
NAME="Send email">
</form>
</center>