Forum Moderators: open

Message Too Old, No Replies

On PageLoad Submit Form

         

scoobydoo987

9:55 pm on Jan 9, 2006 (gmt 0)

10+ Year Member



Is it possible on PageLoad in JavaScript to automatically submit the form as if the user clicked the Submit Button?
------------------------------

<FORM name="dateRange" action="adlist.aspx" method="post">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR bgColor="#c0c0c0">
<TD class="copy">From&nbsp;<INPUT class="normal" id="FromDate" type="text" size="10" name="FromDate"><A href="javascript:cal1.popup();"><IMG alt="Popup Calendar Control" src="/dnfimages/calendar.gif" border="0"></A>
&nbsp;&nbsp;To&nbsp;<INPUT class="normal" id="ToDate" type="text" size="10" name="ToDate"><A href="javascript:cal2.popup();"><IMG alt="Popup Calendar Control" src="/dnfimages/calendar.gif" border="0"></A>
&nbsp;&nbsp; <INPUT class="submit" id="SUBMIT1" type="submit" value="Show" valign="left">
</TD>
</TR>
</TABLE>
</FORM>

Fotiman

10:52 pm on Jan 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think you could do:

<body onload="document.dateRange.submit();">

Haven't tried it though.

scoobydoo987

11:39 pm on Jan 9, 2006 (gmt 0)

10+ Year Member



That works but it keeps loading the page over and over again. I tried adding this but it still keeps loading the page over and over again.

<script language="JavaScript">
<!--
function submitForm(){
for (var n = 0; n < 1; n++){
document.forms[0].submit();
}
}
//-->
</script>

Any ideas?

whoisgregg

11:58 pm on Jan 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The form is posting to itself? If so, it will keep refreshing the page as you are resubmitting the form every page load.

You should be able to set a cookie to keep track of what page load you are on, though.

kaled

10:24 am on Jan 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Depending on what you're trying to achieve, you may need to use an (invisible) IFRAME and specify it as the target of the form.

Kaled.