form submission on same page
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>
Please update the JavaScript method like this -
function CreateMsg() {
var MsgDOM = document.getElementById("MSG");
var duhForm = document.forms[0];
MsgDOM.innerHTML = "Hello, " + duhForm.FNAME.value + " " + duhForm.LNAME.value + ". You're sex is " + duhForm.GENDER.value;
duhForm.target="_self"; // or _top or _parent or _blank
duhForm.action="PleaseAskTheQuestion.do";
duhForm.submit();
}
mu is too short has already submitted the form on the same page, but server is too busy; no donuts for you. :-)
精彩评论