0
的JavaScript:表單提交
function CreateMsg() {
var MsgDOM = document.getElementById("MSG");
MsgDOM.innerHTML = "Hello, " + document.forms[0].FNAME.value + " " + document.forms[0].LNAME.value + ". You're sex is " + document.forms[0].GENDER.value;
}
HTML:
<FORM NAME="DUH">
<INPUT TYPE=TEXT NAME=FNAME>
<INPUT TYPE=TEXT NAME=LNAME>
<SELECT NAME="GENDER">
<OPTION VALUE="Male">Male</OPTION>
<OPTION VALUE="Female">Female</OPTION>
</SELECT>
<BR><BR>
<input type="button" value="Search" onclick="javascript:CreateMsg();"/>
<BR><BR>
<SPAN ID="MSG"> </SPAN>
</FORM>
我只是猜測。您的JS功能無法正常工作,您需要使用ID屬性而不是NAME,同時在HTML中命名您的INPUT。 – 2011-05-12 04:38:04