G
Gobind
Hello
I have been working on this for quite some time now, and have no clue
why my app behaves the way it does.
Here is the code snippet that controls this behaviour.
/////////////////////////////////////////////////////////////////////////////////////
function validateForm()
{
var valid = true;
var today = new Date();
var curdate = today.getFullYear()+"-"+(today.getMonth()
+1)+"-"+today.getDate();
if (compareDates(curdate,"yyyy-M-
d",document.Parms.ENDDATE.value,"yyyy-MM-d") != 0)
{
alert ("blah blah .");
valid = false;
}
return valid;
}
function submitForm(clickbutton)
{
if (clickbutton.name == "submit")
{
if (validateForm())
{
//blah blah
document.top.action = "./task_submitrecord.jsp";
document.Parms.action = "./task_submitrecord.jsp";
document.top.submit();
document.Parms.submit();
}
}
else if (clickbutton.name == "cancel")
{
document.top.action = "./task_init.jsp";
document.Parms.action = "./task_init.jsp";
document.top.submit();
document.Parms.submit();
}
}
/////////////////////////////////////////////////////////////////////////////////////
I have two forms on this page: top and Parms and I intend to submit
them after a validation function has worked its way through to
ensuring all values are the way I want them to be. My validation
function works fine and displays the alert messages as I want them. I
check for the valid variable in the submitForm function and only do
the submit action after validation has returned true! Although I see
the error messages which guarantees that valid has been set to false,
why does my page refresh at all? It does not go to the next page, but
it refreshes the same page and loses half the interface information.
If all the information is correct and no error messages are found,
then the new link is opened and the functionality is completed. But if
validation results in an error, then the same page keeps refreshing
itself (I hope this is clear enough).
I can press the back button to restore the page (which could be a
workaround for this case), but I would like to know what exactly is
screwing this up? Is it the multiple forms being submitted together or
is it something else? Thanks in advance.
I have been working on this for quite some time now, and have no clue
why my app behaves the way it does.
Here is the code snippet that controls this behaviour.
/////////////////////////////////////////////////////////////////////////////////////
function validateForm()
{
var valid = true;
var today = new Date();
var curdate = today.getFullYear()+"-"+(today.getMonth()
+1)+"-"+today.getDate();
if (compareDates(curdate,"yyyy-M-
d",document.Parms.ENDDATE.value,"yyyy-MM-d") != 0)
{
alert ("blah blah .");
valid = false;
}
return valid;
}
function submitForm(clickbutton)
{
if (clickbutton.name == "submit")
{
if (validateForm())
{
//blah blah
document.top.action = "./task_submitrecord.jsp";
document.Parms.action = "./task_submitrecord.jsp";
document.top.submit();
document.Parms.submit();
}
}
else if (clickbutton.name == "cancel")
{
document.top.action = "./task_init.jsp";
document.Parms.action = "./task_init.jsp";
document.top.submit();
document.Parms.submit();
}
}
/////////////////////////////////////////////////////////////////////////////////////
I have two forms on this page: top and Parms and I intend to submit
them after a validation function has worked its way through to
ensuring all values are the way I want them to be. My validation
function works fine and displays the alert messages as I want them. I
check for the valid variable in the submitForm function and only do
the submit action after validation has returned true! Although I see
the error messages which guarantees that valid has been set to false,
why does my page refresh at all? It does not go to the next page, but
it refreshes the same page and loses half the interface information.
If all the information is correct and no error messages are found,
then the new link is opened and the functionality is completed. But if
validation results in an error, then the same page keeps refreshing
itself (I hope this is clear enough).
I can press the back button to restore the page (which could be a
workaround for this case), but I would like to know what exactly is
screwing this up? Is it the multiple forms being submitted together or
is it something else? Thanks in advance.