Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-19-2002, 09:14 PM   PM User | #1
elo
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
elo is an unknown quantity at this point
redirect

I have a mail form that works correctly in IE but not in netscape. Actually in netscape the form works but will not redirect to the "thank you for inquiry" page. this is what i'm using to redirect.

pform.action="mailto:gino@blah.com";
// put the redirect url in here absolute or relative urls can be used
location.href="thanks.html";

could i put a script on the "Submit" button" to redirect it once it is submitted? Any suggestions would be greatly appreciated!

Thanks
elo is offline   Reply With Quote
Old 06-19-2002, 09:26 PM   PM User | #2
whackaxe
Senior Coder

 
Join Date: Jun 2002
Location: paris, france
Posts: 1,216
Thanks: 0
Thanked 0 Times in 0 Posts
whackaxe is an unknown quantity at this point
i havnt got netscape but maybe you should use the whole sytax I.E:
window.document.location.href

someone should start a petition for making netscape and IE use the W3 norm
__________________
photoshop too expensive? use the GIMP! www.gimp.org
whackaxe is offline   Reply With Quote
Old 06-19-2002, 09:43 PM   PM User | #3
elo
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
elo is an unknown quantity at this point
yea, unfortunately that didn't work either.
elo is offline   Reply With Quote
Old 06-19-2002, 10:19 PM   PM User | #4
x_goose_x
Regular Coder

 
Join Date: Jun 2002
Location: Montreal, Canada
Posts: 644
Thanks: 0
Thanked 0 Times in 0 Posts
x_goose_x is an unknown quantity at this point
what about:

location.replace("thankyou.htm")
x_goose_x is offline   Reply With Quote
Old 06-19-2002, 10:31 PM   PM User | #5
JohnKrutsch
Regular Coder

 
Join Date: Jun 2002
Location: The Planet Earth Code Poet: True
Posts: 282
Thanks: 0
Thanked 1 Time in 1 Post
JohnKrutsch is an unknown quantity at this point
What about posting your whole script so we can have a look?
JohnKrutsch is offline   Reply With Quote
Old 06-19-2002, 10:35 PM   PM User | #6
elo
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
elo is an unknown quantity at this point
no, unfortunately that didn't work either. Also, I just found out that the script doesn't work on mac browsers. Does anyone have a crossbrowser javascript for a simple form to submit info to an email address? in the form i have first, last name, address1, address2, city, state, zip, phone email, url , comments.
elo is offline   Reply With Quote
Old 06-19-2002, 10:38 PM   PM User | #7
elo
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
elo is an unknown quantity at this point
here is the script.
<script language="JavaScript" type="text/javascript">
<!-- Hide script from older browsers
// This script validates fields, returns error messages, submits form and redirects page

// Ensure that ESSENTIAL FIELDS have been filled in.
function CheckFields(pform) {

// The fields are checked for blanks
if ( pform.FIRSTNAME.value == "" ||
pform.SURNAME.value == "" ||
pform.EMAIL.value == "" ||
pform.ADDRESS.value == "" ||
pform.CITY.value == "" ||
pform.STATE.value == "" ||
pform.POSTCODE.value == "" ||
pform.PHONE.value == "" ) {
alert( "Data in essential fields missing.\nPlease ensure that all fields are filled in." );
return false;
}

// check for valid email address
else if ( pform.EMAIL.value.length <= 6 ||
pform.EMAIL.value.indexOf ('@', 0) == -1 ||
pform.EMAIL.value.indexOf ('.', 0) == -1){

alert("'' " + pform.EMAIL.value + " '', is not valid Email Address.");
return false;
}


else {

// If reached this far then thank user, submit form and show redirect page

alert ("'Thank you for your registration submission.'" +pform.FIRSTNAME.value + " '' \nPlease wait a moment while your data is sent to our server")

// put your email address in here
pform.action="mailto:ricky@xtramayo.com";
// put the redirect url in here absolute or relative urls can be used
window.document.location.href ="thanks.html";


return true;
}

}

//End Hiding -->
</script>
elo is offline   Reply With Quote
Old 06-19-2002, 11:18 PM   PM User | #8
JohnKrutsch
Regular Coder

 
Join Date: Jun 2002
Location: The Planet Earth Code Poet: True
Posts: 282
Thanks: 0
Thanked 1 Time in 1 Post
JohnKrutsch is an unknown quantity at this point
try changing this line:

window.document.location.href ="thanks.html";

to this:

setTimeout("location='thanks.html',500)


This type of script is dependant on the users email client so that may be why it wont work for some people.
JohnKrutsch is offline   Reply With Quote
Old 06-20-2002, 12:17 AM   PM User | #9
elo
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
elo is an unknown quantity at this point
thanks but that didn't work either. also, if it is dependant on the users email client does that mean if I'm in netscape I have to use netscape as my email client for the form to work? Could you recommend a place for me to go and find one that isn't ?
elo is offline   Reply With Quote
Old 06-20-2002, 01:42 AM   PM User | #10
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
Unfortunately, the only way to get around the user's dependency upon their email client is to send an email (and redirect) using server-side scripting.

Actually, my free formmail at http://www.solidscripts.com does what you want (as do about a half-dozen (possibly more) others on the internet, like http://www.bravenet.com and www.formbuddy.com - those are the only two others I can remember offhand) -

Basically these services allow you to post your form to a remote server, it then emails the form contents to you, and then redirects to whatever "thankyou" page you have set up on your website.

I would also recommend learning a server-side language of your choice... then you can do pretty much whatever you want!!!

Hope this helps!
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)

Last edited by whammy; 06-20-2002 at 01:44 AM..
whammy is offline   Reply With Quote
Old 06-20-2002, 11:42 PM   PM User | #11
elo
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
elo is an unknown quantity at this point
great! I really appreciate it.
elo is offline   Reply With Quote
Old 06-20-2002, 11:51 PM   PM User | #12
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
P.S. JohnKrutsch's solution above would usually work (even though there are still problems relying on the "mailto" action)... he just left out the closing double quote...

setTimeout("window.location='thankyou.htm'",500)
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)
whammy is offline   Reply With Quote
Old 06-20-2002, 11:54 PM   PM User | #13
elo
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
elo is an unknown quantity at this point
yea, i did notice the end quote. does it need a ; at the end?
elo is offline   Reply With Quote
Old 06-21-2002, 12:21 AM   PM User | #14
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
Not technically - as javascript when compiled will add a ; if it isn't there...

But it's good coding practice to include the ; where it should be... i.e. like this:

var foobar = "Muahaha";
if(1=1){
alert(foobar);
}
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)
whammy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:36 PM.


Advertisement
Log in to turn off these ads.