473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with redirecting to another page after submitting

14
Hi, i have a form and i use cgi script to email the results back to me.

I have a javascript in there already that checks if the required fields are filled when you click submit and if they are not there is a pop up that says these fields are not filled in.

When i fill them all in and click submit it works great but it takes me to like cgi-bin/cgimail page that says something like "Success etc....." but i want to change this to lets say a confirmation page on my web site.

Now i ran into a problem, my java code says when submit is hit to validate the fields and when i tried to use this code below a onClick="jump()" in the submit tags on the bottom of my form, it would take me to another page everytime even when all the fields are empty and i press submit, it will pop up and say these fields are not filled in, but then the page would change and i dont want that.

Can anyone help me since im pretty new with java and all i want is, when i click the submit and pop up comes up not to go to another page, but remaiin on the form, And Finally when all the required fields are typed in and customer clicks Submit again, if everything is fine, THEN go to another page and email would be sent to me.

The script is below....

One question is if i add like if/then statement (ex. if function validation() is true then location.href="thankyou.html"??? How would i write this code and where would i put it?



Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--
  3. function validate() {
  4. with (document.form1) {
  5. var alertMessage = "The following REQUIRED fields\nhave been left empty:\n";
  6. if (name.value == "") {
  7. alertMessage += "\nName" }
  8. if (address.value == "") {
  9. alertMessage += "\nAddress" }
  10. if (city.value == "") {
  11. alertMessage += "\nCity" }
  12. if (state.value == "") {
  13. alertMessage += "\nState" }
  14. if (zip.value == "") {
  15. alertMessage += "\nZip Code" }
  16. if (county.value == "") {
  17. alertMessage += "\nCounty" }
  18. if (email.value == "") {
  19. alertMessage += "\nEmail" }
  20. if (pricerange.value == "") {
  21. alertMessage += "\nPlease enter your price range" }
  22. if (alertMessage != "The following REQUIRED fields\nhave been left empty:\n") {
  23. alert(alertMessage);
  24. return (false);
  25. }
  26. return (true);
  27. }
  28. }
  29. // -->
  30. </script>
  31.  
  32. <form action="cgi-bin/cgiemail" method="post" onsubmit="return validate()" form
  33.  
  34. name="form1">
  35.  
  36.  
Any help would be appreciated
thanks
slavisa
Apr 13 '07 #1
1 2858
slavisa
14
got it to work, thanks
Apr 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Rick | last post by:
Hello, I'm having trouble with submitting my form when checking to see if data is present in the user-inputted fields. What I want to happen is for the user to input various pieces of data,...
1
by: Bilbo | last post by:
Hello, How do I programatically redirect a page in "another frame" using C# in ASP.NET? Server.Transfer redirects the current page...not a different frame. Thanks.
4
by: Greg Smalter | last post by:
Redirecting from page to page within a web project is pretty easy. However, all Redirect methods take strings as arguments, as if you mistype the string, you don't find out until run time that you...
0
by: Dynamo | last post by:
Firstly, many thanks to those who replied to my dreaded what if question. As a result I have now been able to partially resolve my problem as follows: step 1 - User clicks on "buy me" button step...
19
by: Justin | last post by:
Harlow... i need some help on these... im actually trying to do a page using php... the function is to receive certain parameters from a 3rd party provider... and i need to redirect my page to...
1
by: gbezas | last post by:
Hi All, I have added an event handler to redirect form.submit() to a newSubmit() method that I have defined (which does some additional processing before submitting the form). Additionally I...
41
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to...
9
by: Jonathan Wood | last post by:
I've spent days trying to come up with a solution. I'd appreciate it if anyone can help. My site requires all users to log on. There are three different roles of users, and each user type will...
3
by: sbettadpur | last post by:
hello all, i have one problem, after submitting form values into database table, at the same time page has redirect to another page i.e email form but i am getting error as header already sent....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.