K
kelvin
Hi,
I've this piece of code which does not work at all.
Can anyone point out my mistake?
I've 2 buttons. History button will call verifyFields() function and
lead to
different page for processing. verifyFields() is working fine and so
does the
history() function.
But,
the other save button doesn't work. It's supposed to call the save()
function and before executing the action, it will perform a check by
executing
checkFormFields(). However it does not execute these statements:
--------------------------------------------------------------------
document.ListForm.target="origin";
document.ListForm.action="ListByOrigin_updaterecord.asp?action=check";
--------------------------------------------------------------------
The links above have been verified and it's working.
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkFormFields()
{
if(!isNumber(ListForm.destination.value))
{
alert("Destination must not contain numbers at all.");
ListForm.destination.focus();
return false;
}
return true;
}
function history()
{
document.ListForm.target="adhoc";
document.ListForm.action="ListByOrigin.asp?action=check";
}
function save()
{
if (checkFormFields() ) //doesn't execute these 2 lines.
{
document.ListForm.target="origin";
document.ListForm.action="ListByOrigin_updaterecord.asp?action=check";
return true;
}
}
//-->
</script>
<form action="" method="post" name="ListForm" onSubmit="return
verifyFields();">
<input name="submit" type="submit" value="History"
onClick="history()">
<input name="submit" type="submit" id="submit" value="Save"
onClick="return save();">
</form>
I've this piece of code which does not work at all.
Can anyone point out my mistake?
I've 2 buttons. History button will call verifyFields() function and
lead to
different page for processing. verifyFields() is working fine and so
does the
history() function.
But,
the other save button doesn't work. It's supposed to call the save()
function and before executing the action, it will perform a check by
executing
checkFormFields(). However it does not execute these statements:
--------------------------------------------------------------------
document.ListForm.target="origin";
document.ListForm.action="ListByOrigin_updaterecord.asp?action=check";
--------------------------------------------------------------------
The links above have been verified and it's working.
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkFormFields()
{
if(!isNumber(ListForm.destination.value))
{
alert("Destination must not contain numbers at all.");
ListForm.destination.focus();
return false;
}
return true;
}
function history()
{
document.ListForm.target="adhoc";
document.ListForm.action="ListByOrigin.asp?action=check";
}
function save()
{
if (checkFormFields() ) //doesn't execute these 2 lines.
{
document.ListForm.target="origin";
document.ListForm.action="ListByOrigin_updaterecord.asp?action=check";
return true;
}
}
//-->
</script>
<form action="" method="post" name="ListForm" onSubmit="return
verifyFields();">
<input name="submit" type="submit" value="History"
onClick="history()">
<input name="submit" type="submit" id="submit" value="Save"
onClick="return save();">
</form>