Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit Button

Status
Not open for further replies.

lomano

Programmer
Nov 15, 2000
18
CA
I am using the submit button to submit information via an e-mail.. I'm using the mailto, which is fine... Is it possible to also once the button is pressed to redirect the webpage to another webpage.. I have tried writing functions for onclick and on submit, but with no success
 
post your code and maybe I can help you a bit. jared@aauser.com
 
Thanks i would really appreciate it... It seems the onclick overrides the mailto action

<form method=&quot;POST&quot; enctype=&quot;text/plain&quot; name=&quot;testing&quot;
action=&quot;mailto:standevend@inac.gc.ca&quot;>
<input type=&quot;hidden&quot; name=&quot;~&quot;
value=&quot;========================================================&quot;><input type=&quot;hidden&quot;
name=&quot;~&quot; value=&quot;Boardroom Booking Form&quot;><input type=&quot;hidden&quot; name=&quot;Contact Name &quot;
value=&quot;<%=request.form(&quot;contact&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Phone # &quot;
value=&quot;<%=request.form(&quot;phone&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Subject of Meeting &quot;
value=&quot;<%=request.form(&quot;subject&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Room Preference &quot;
value=&quot;<%=request.form(&quot;room&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Number of Participants &quot;
value=&quot;<%=request.form(&quot;part&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Who &quot;
value=&quot;<%=request.form(&quot;who&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Hardware/Equipment &quot;
value=&quot;<%=request.form(&quot;equip&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Date Requested From &quot;
value=&quot;<%=request.form(&quot;date1&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Date Requested to &quot;
value=&quot;<%=request.form(&quot;date2&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Time Requested From &quot;
value=&quot;<%=request.form(&quot;time1&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Time Requested To &quot;
value=&quot;<%=request.form(&quot;time2&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Internal/External &quot;
value=&quot;<%=request.form(&quot;Internal&quot;)%>&quot;><input type=&quot;hidden&quot; name=&quot;Hospitality Required &quot;
value=&quot;<%=request.form(&quot;hospital&quot;)%>&quot;><input type=&quot;hidden&quot;
name=&quot;Special Room Configurations/Instructions&quot; value=&quot;<%=request.form(&quot;special&quot;)%>&quot;><div
align=&quot;center&quot;><center><p><br>
<br>
<input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot; onClick=&quot;window.location='newformtest.htm';&quot;><input
TYPE=&quot;button&quot; VALUE=&quot;Go Back&quot; onClick=&quot;history.go(-1)&quot;></p>
</center></div>
</form>
 
I have solved your prosing the following:

<input type=&quot;button&quot; value=&quot;submit&quot; name=&quot;imposter&quot; onClick=&quot;document.form.B1.click();document.location.replace('replacement.htm');&quot;>
<input type=&quot;submit&quot; style=&quot;visibility:hidden&quot; value=&quot;Submit&quot; name=&quot;B1&quot;>

by using another button, we can avoid the problem, and everyone is happy! I hope this solves at least some of your probs!

Ben
 
Sorry look that code does work, but it does not give enough time for the browser to send the mail, so what i did was this, instead of :

onClick=&quot;document.location.replace('replacement.htm')&quot;


just call a function like this, or put the whole lot in the onClick handler:


function sender(){
setInterval('document.location.replace(&quot;nextPage.htm&quot;)',1000)

}


[/color][/b]
This way we stay on the page long enough for the mail to be sent.
Works sweet as now. Actually I never realised you could submit data that way! I have never used it.

Ben.
 
So the onclick for the button called imposter becomes:

<input type=&quot;button&quot; value=&quot;submit&quot; name=&quot;imposter&quot; onClick=&quot;document.form.B1.click;sender()&quot;>



 
why did noone though of :
<form action=&quot;mailto:....&quot; method=&quot;post&quot; onsubmit=&quot;javascript:sender()&quot;> ?? won't it work ?

the onclick event on the submit button overrides the onsubmit event and even the action sometimes
but using onsubmit in the form tag works fine : first the jscript function is called, and if it returns true, then the action of the form is called ... isn't that what you wanted to do ?
 
I am going to try out all of this stuff today, I appreciate all your help thanks
 
Hi iza, no it does not work, this action seems to forget about any onClick events after mailing, this is why we are trying other ways.
I am not sure why this is, it is a bit weird!

It seems we want to change pages after the form has been submitted also, not before, otherwise there is not time for it to be set.

Actually, I have now found that calling sender() onClick does work, although calling onSubmit does not!

I think this is simply the time thing, because if i remove the delay, then it does not work!

- Use a function with setInterval.
- Use it onClick (not onSubmit)


try it out anyway, sorry to be so confusing!
Ben
 
Thanks for everyones help.. I got the effect i was looking for... quick note I had to increase the interval so that it would work in netscape

Thanks Again
 
the onsubmit (in the FORM tag) is fired BEFORE the action even if the action is a mailto
i've done that and it works ;] (no onclick ! nothing on the submit button !)
but i'm glad you found your way
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top