View Full Version : null error
crmpicco
03-30-2005, 11:37 AM
I have a form called 'fexp' and two hidden fields called 'multileg' and 'submitcounter', and they both have values of 'true' to start with. I have a Javascript function as per below:
function submitvalues()
{
if ((document.fexp.multileg.value == true)&&(document.fexp.submitcounter.value == true))
{
document.fexp.submit();
document.fexp.multileg.value == false;
document.fexp.submitcounter.value == false;
}
}
I call it in the <body> tag:
<body bgcolor="#f5f5f5" leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 onload="setframe();document.fexp.depapt.focus();return submitvalues();">
But i keep get this error:
document.fexp.multileg.value is null or not a object.
However, it is DEFINATELY there:
<input type="hidden" name="multileg" value="<%=multileg%>">
<input type="hidden" name="submitcounter" value="<%=submitcounter%>">
should be:
function submitvalues()
{
if ((document.fexp.multileg.value == true)&&(document.fexp.submitcounter.value == true))
{
document.fexp.submit();
document.fexp.multileg.value = "false";
document.fexp.submitcounter.value = "false";
}
}
crmpicco
03-30-2005, 01:24 PM
I now have:
function submitvalues()
{
if ((document.fexp.multileg.value == "true")&&(document.fexp.submitcounter.value == "true"))
{
document.fexp.submit();
document.fexp.multileg.value == "false";
document.fexp.submitcounter.value == "false";
}
}
But it just KEEPS on submitting???
How do i make it do it ONCE?
you're still writing the code wrong. it's not a double equals (==) which is a comparison operator, but a single equals (=) or assignment operator, you need. kapiche?
also, to make the page only submit the once you need to check that it's not already been submitted. to do that, you need to set a hidden field on submit and then check for that value on load. if it exists in the URL, then the page has already been submitted and so you abort the event.
crmpicco
03-30-2005, 02:10 PM
have you got code for this?
thanks for your help.
also discussed at:
http://p2p.wrox.com/topic.asp?TOPIC_ID=28582
what do these fields do:
<input type="hidden" name="multileg" value="<%=multileg%>">
<input type="hidden" name="submitcounter" value="<%=submitcounter%>">
crmpicco
03-30-2005, 02:22 PM
they originally hold the value 'true' but are changed to false with the JS.
they originally hold the value 'true' but are changed to false with the JS.
yeah, but what for ... that's what I'm asking?
crmpicco
03-30-2005, 02:31 PM
nothing really,
<form name="fexp" method="post" action="">
multileg<input type="text" name="multileg" value="<%=multileg%>">
subcount<input type="text" name="submitcounter" value="<%=submitcounter%>">
crmpicco
03-30-2005, 02:38 PM
i just want to submit the form 'fexp' ONCE when the page loads. how is this done?
i just want to submit the form 'fexp' ONCE when the page loads. how is this done?
stop shouting. furthermore, stop demanding it be done. this site is not your personal answering service. it's a community of volunteers who help each other.
now, you've already got the answer. yes, you don't have the code. but you should be competent enough to figure that out for yourself. I was going to do this for you, but because of your impatience I'm now having second thoughts.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.