Hi,
I have a html page which accepts two inputs (number) from user, and calls a Javascript function doSubmit(form) to check if the input is valid. If not, pop up a alert window, and cancell the form submission. Then, after the user re-input, it should submit the form. But my program does not do it right. If I remove the line
onClick="document.myform.submit()" away from my js code, it just hang on there.
Can anyone tell why? Am I doing something wrong with the event trigger onSumbit="" or onCleck=""? Thanks.
michael
following are the segments of of html and js code.
--------------- fill.html ----------------------
<HTML>
<HEAD>
<TITLE>Fill History</TITLE>
<SCRIPT LANGUAGE="JavaScript" SRC="showfill.js"></SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFE1">
<TABLE border="0" width=100% >
<TR bgcolor=darkblue>
<TD><FONT face="Verdana, Arial, Helvetica"
size="3" color=white> <strong>Central Fill History for a Given Store Number
and Rx Number</strong></FONT></TD>
</TR>
</TABLE>
<FORM name="myform" method="post" action="/webapp/ToolBox/servlet/walgreens.show
fill.proxy.ShowfillProxy/ShowfillReport" onSubmit="return doSubmit(myform)">
<p><font face="Verdana, Arial, Helvetica" size="2"><b>
Enter the following information:</b></font></p>
<font color="#000099"></font>
<pre><strong><font face="Verdana, Arial, Helvetica">
Store number: <input type="text" name="storeNbr">
Rx number: <input type="text" name="rxNbr">
</font></strong></pre>
<BR><BR>
<table border="0" width="75%">
<tr>
<td width="30%" height="15" valign="bottom">
<input type="submit" value="Submit" onClick="document.myform.submit()">
<td width="30%" height="15" valign="bottom">
<input type="reset" value="Clear Form"></td>
</tr>
</table>
<SCRIPT language="JavaScript"> document.myform.storeNbr.focus(); </SCRIPT>
</FORM>
<br>
<table border="0" width="75%">
<tr><td width="50%" height="15" valign="bottom">
<font face="verdana,arial,helvetica" size="2"><a href="JavaScript:history.back(1
)"><strong>Back</strong></a></font></td>
<td width="50%" height="15" valign="bottom">
<a href="
<font face="Verdana, Arial, Helvetica">RxS</font></small></strong></a></td></tr>
</table>
<p> </p>
</BODY>
</HTML>
--------------- showfill.js --------
var theflag = true;
function chkStoreNbr(){
/* Store# can only be numbers */
if (notNumber(document.myform.storeNbr.value) == true)
{
alert ("Please enter only numbers in Store# field"
;
document.myform.storeNbr.focus();
theflag = false;
}
}
function chkRxNbr(){
if (notNumber(document.myform.rxNbr.value) == true)
{
alert ("Please enter only numbers in Rx# field"
;
document.myform.rxNbr.focus();
theflag = false;
}
}
function doSubmit(myform){
chkRxNbr();
if(!theflag) return theflag;
chkStoreNbr();
if(!theflag) return theflag;
return theflag;
/* document.myform.submit(); */
}
I have a html page which accepts two inputs (number) from user, and calls a Javascript function doSubmit(form) to check if the input is valid. If not, pop up a alert window, and cancell the form submission. Then, after the user re-input, it should submit the form. But my program does not do it right. If I remove the line
onClick="document.myform.submit()" away from my js code, it just hang on there.
Can anyone tell why? Am I doing something wrong with the event trigger onSumbit="" or onCleck=""? Thanks.
michael
following are the segments of of html and js code.
--------------- fill.html ----------------------
<HTML>
<HEAD>
<TITLE>Fill History</TITLE>
<SCRIPT LANGUAGE="JavaScript" SRC="showfill.js"></SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFE1">
<TABLE border="0" width=100% >
<TR bgcolor=darkblue>
<TD><FONT face="Verdana, Arial, Helvetica"
size="3" color=white> <strong>Central Fill History for a Given Store Number
and Rx Number</strong></FONT></TD>
</TR>
</TABLE>
<FORM name="myform" method="post" action="/webapp/ToolBox/servlet/walgreens.show
fill.proxy.ShowfillProxy/ShowfillReport" onSubmit="return doSubmit(myform)">
<p><font face="Verdana, Arial, Helvetica" size="2"><b>
Enter the following information:</b></font></p>
<font color="#000099"></font>
<pre><strong><font face="Verdana, Arial, Helvetica">
Store number: <input type="text" name="storeNbr">
Rx number: <input type="text" name="rxNbr">
</font></strong></pre>
<BR><BR>
<table border="0" width="75%">
<tr>
<td width="30%" height="15" valign="bottom">
<input type="submit" value="Submit" onClick="document.myform.submit()">
<td width="30%" height="15" valign="bottom">
<input type="reset" value="Clear Form"></td>
</tr>
</table>
<SCRIPT language="JavaScript"> document.myform.storeNbr.focus(); </SCRIPT>
</FORM>
<br>
<table border="0" width="75%">
<tr><td width="50%" height="15" valign="bottom">
<font face="verdana,arial,helvetica" size="2"><a href="JavaScript:history.back(1
)"><strong>Back</strong></a></font></td>
<td width="50%" height="15" valign="bottom">
<a href="
<font face="Verdana, Arial, Helvetica">RxS</font></small></strong></a></td></tr>
</table>
<p> </p>
</BODY>
</HTML>
--------------- showfill.js --------
var theflag = true;
function chkStoreNbr(){
/* Store# can only be numbers */
if (notNumber(document.myform.storeNbr.value) == true)
{
alert ("Please enter only numbers in Store# field"
document.myform.storeNbr.focus();
theflag = false;
}
}
function chkRxNbr(){
if (notNumber(document.myform.rxNbr.value) == true)
{
alert ("Please enter only numbers in Rx# field"
document.myform.rxNbr.focus();
theflag = false;
}
}
function doSubmit(myform){
chkRxNbr();
if(!theflag) return theflag;
chkStoreNbr();
if(!theflag) return theflag;
return theflag;
/* document.myform.submit(); */
}