Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 497
  • Last Modified:

how to redirect to a page once the form(mailto) is submitted.

These are part of my codes:

function redirect()
{
setTimeout('this.document.location.href="C:/a_Bak_William/thank_you.htm"',2500);
}
.........
.........
.........
<form action="mailto:abc@abc.com" method="post"
          enctype="text/plain" name="mailForm"
           onSubmit="return validateEmail() && checkFields() && mailIt(this) && redirect()">
          ..........................
    <p><input type="submit" value="Submit"></p>
</form>    

Once i click the submit button, there will be pop up Microsoft Internet Explorer box saying "This form is being submitted using email, etc...However if i click cancel, it redirect to the thank_you page immediately instead of remain on the same page.

Is there any way that i can do using javascript instead of doing on the server side or using cgi script?
Please help me experts....

thanks in advance.
0
cozyboi
Asked:
cozyboi
  • 8
  • 5
  • 4
  • +3
1 Solution
 
boxy73Commented:
I'm not sure because I don't have all your code, but I think you should not use setTimeOut directly with location.href.

For example, you could insert that code in a function called fncRedirection (). This should be the function called from redirect () in the setTimeOut.

function redirect()
{
    setTimeout ('fncRedirection ();',2500);
}

You could define a global variable bolRedirect = true;

And if you receive from the modal window the cancel operation, just change bolRedirect = false;

Finally, the fncRedirection should be something like:


fncRedirection ()
{
  if (bolRedirect)
this.document.location.href="C:/a_Bak_William/thank_you.htm"';
}
0
 
webwomanCommented:
First of all, you do NOT want a link with a drive letter.

Second, find out if your ISP/hosting company has a REAL form handler. Chances are they do, and it will actually WORK as opposed to mailto, which may or may not work, and you have no control over which it is.
0
 
cozyboiAuthor Commented:
To boxy73,

How do I control the modal window? where should i insert

bolRedirect=false? The modal window pop up automatically

and there is no way I can control it.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
cozyboiAuthor Commented:
To webwoman,

Can I explain to me in more detail? Does it mean

that i should upload it to the web using my hosting

company?

At moment, I want to try on local drive to see whether

it works or not.
0
 
elhyCommented:
u don't have to specify the full path. if this form lies in the same directory (a_Bak_William) just specify thank_you.htm will do. I've modified your redirect function. See if this works.


function redirect()
{
  if(validateEmail() && checkFields() && mailIt(document.mailForm)){
setTimeout('this.document.location.href="thank_you.htm"',2500);
  }
}
.........
.........
.........
<form action="mailto:abc@abc.com" method="post"
         enctype="text/plain" name="mailForm"
          onSubmit="return redirect();">
         ..........................
   <p><input type="submit" value="Submit"></p>
</form>  
0
 
cozyboiAuthor Commented:
To elhy,

I don't think it has any difference from my previous

coding. I show some more of my coding, hope you or other

experts can help me, thanks


function redirect()
{
     window.location.href="C:/a_Bak_William/thank_you.htm";


}


function mailIt(form1) {
  var name = form.Name.value
  var handphone = form.Handphone.value
  var email = form.Email.value
  var DA1DD = form.DA1DD.value
  var DA1MM = form.DA1MM.value
  var DA1YY = form.DA1YY.value
  var DA1Hr = form.DA1Hr.value
  var DA1Min = form.DA1Min.value
  var DA1AMPM = form.DA1AMPM.value
  var RA1D = form.RA1D.value
  var PurposeApp1 = form.PurposeApp1.value
 
 
  var userInfo = ""

  userInfo += " " + name + "\n\n"
  userInfo += "Handphone= " + handphone + "\n\n"
  userInfo += "Email= " + email + "\n\n"
  userInfo += "Date of 1st Appointment= " + DA1DD + " " + DA1MM + " " + DA1YY + "  " + DA1Hr + ":" + DA1Min + DA1AMPM + "\n\n"
  userInfo += "Purpose of 1st Appointment= Remind patient " + RA1D + " before appointment time." + "\n\n"
  userInfo += "Purpose of 1st Appointment= " + PurposeApp1 + " on " + DA1DD + " " + DA1MM + " " + DA1YY + "  " + DA1Hr + ":" + DA1Min + DA1AMPM + "\n\n"
 
 
  try{
  userInfo += "Date of 2nd Appointment= " + form.DA2DD.value + " " + form.DA2MM.value + " " + form.DA2YY.value + "  " + form.DA2Hr.value + ":" + form.DA2Min.value + form.DA2AMPM.value + "\n\n"
  userInfo += "Purpose of 2nd Appointment= Remind patient " + form.RA2D.value + " before appointment time." + "\n\n"
  userInfo += "Purpose of 2nd Appointment= " + form.PurposeApp2.value + " on " + form.DA2DD.value + " " + form.DA2MM.value + " " + form.DA2YY.value + "  " + form.DA2Hr.value + ":" + form.DA2Min.value + form.DA2AMPM.value + "\n\n"
  }catch(e){}
  form1.Name.value = userInfo
  return true
 
  document.write("<html><head></head><body>")
  document.write("<p><h3>Thank You</h3></p>")
  docment.write("</body></html>")

}
........
........
........
........

<form name=form>
......
"form fields etc...."
......
</form>

<form action="mailto:sms@mhchealthcare.com" method="post"
          enctype="text/plain" name="mailForm"
           onSubmit="return validateEmail() && checkFields() && mailIt(this) && setTimeout('redirect()',2500)">
    <input type="hidden" name="Name" >
    <p><input type="submit" value="Submit"></p>
</form>  
0
 
cozyboiAuthor Commented:
To elhy,

I don't think it has any difference from my previous

coding. I show some more of my coding, hope you or other

experts can help me, thanks


function redirect()
{
     window.location.href="C:/a_Bak_William/thank_you.htm";


}


function mailIt(form1) {
  var name = form.Name.value
  var handphone = form.Handphone.value
  var email = form.Email.value
  var DA1DD = form.DA1DD.value
  var DA1MM = form.DA1MM.value
  var DA1YY = form.DA1YY.value
  var DA1Hr = form.DA1Hr.value
  var DA1Min = form.DA1Min.value
  var DA1AMPM = form.DA1AMPM.value
  var RA1D = form.RA1D.value
  var PurposeApp1 = form.PurposeApp1.value
 
 
  var userInfo = ""

  userInfo += " " + name + "\n\n"
  userInfo += "Handphone= " + handphone + "\n\n"
  userInfo += "Email= " + email + "\n\n"
  userInfo += "Date of 1st Appointment= " + DA1DD + " " + DA1MM + " " + DA1YY + "  " + DA1Hr + ":" + DA1Min + DA1AMPM + "\n\n"
  userInfo += "Purpose of 1st Appointment= Remind patient " + RA1D + " before appointment time." + "\n\n"
  userInfo += "Purpose of 1st Appointment= " + PurposeApp1 + " on " + DA1DD + " " + DA1MM + " " + DA1YY + "  " + DA1Hr + ":" + DA1Min + DA1AMPM + "\n\n"
 
 
  try{
  userInfo += "Date of 2nd Appointment= " + form.DA2DD.value + " " + form.DA2MM.value + " " + form.DA2YY.value + "  " + form.DA2Hr.value + ":" + form.DA2Min.value + form.DA2AMPM.value + "\n\n"
  userInfo += "Purpose of 2nd Appointment= Remind patient " + form.RA2D.value + " before appointment time." + "\n\n"
  userInfo += "Purpose of 2nd Appointment= " + form.PurposeApp2.value + " on " + form.DA2DD.value + " " + form.DA2MM.value + " " + form.DA2YY.value + "  " + form.DA2Hr.value + ":" + form.DA2Min.value + form.DA2AMPM.value + "\n\n"
  }catch(e){}
  form1.Name.value = userInfo
  return true
 
  document.write("<html><head></head><body>")
  document.write("<p><h3>Thank You</h3></p>")
  docment.write("</body></html>")

}
........
........
........
........

<form name=form>
......
"form fields etc...."
......
</form>

<form action="mailto:abc@abc.com" method="post"
          enctype="text/plain" name="mailForm"
           onSubmit="return validateEmail() && checkFields() && mailIt(this) && setTimeout('redirect()',2500)">
    <input type="hidden" name="Name" >
    <p><input type="submit" value="Submit"></p>
</form>  
0
 
elhyCommented:
questions:

1. Why do you have two forms? The submit btn etc should be within the same form tag.

Not sure if you can control that confirmation msg coz its brought up by IE/windows. I doubt so. But if anyone knows how to control please post here. I'm interest to know too.
0
 
boxy73Commented:
Can't you pass the window object as a parameter from your main window the the popup one? If so, you could use it to access the global variable bolRedirect and change its value.



0
 
Commodus2Commented:
You can use the confirm()

function submitForm(){

}
0
 
Commodus2Commented:
You can use the confirm()

function submitForm(){
   if (confirm("will be emailed")) {
      // call all the email function here
      // and return false if an error occurs
      validateEmail();
      checkFields();
      mailIt(this);
      setTimeout('redirect()',2500);
   }    
}
function redirect(){
   document.location.href = "thanks.html";
}


<form action="mailto:abc@abc.com" method="post"
         enctype="text/plain" name="mailForm"
          onSubmit="submitForm()">
   <input type="hidden" name="Name" >
   <p><input type="submit" value="Submit"></p>
</form>


mayby it is not correct, but i'm giving a shot
0
 
cozyboiAuthor Commented:
To boxy73,

Can you explain to me further as in produce some codings

or examples? Coz I think there is no way i can control the

confirmation msg box.

Thanks alot.
0
 
elhyCommented:
Commodus2:

I thought this statement "if (confirm("will be emailed")) {" will create a new confirmation popup?? Please advice if I'm wrong.
0
 
boxy73Commented:
What are you using for the popup window? A window.showModalDialog (popup-address, parameters, ...); ?

If so, in the parameters just pass window.

In the modal window, just type at the beginning of the Javascript code:

var objParent = window.dialogArguments;

And now you will have full access to parent's global Javascript variables (including bolRedirect) and functions.

If not using showModalDialog, what are you using for the popup window?


0
 
cozyboiAuthor Commented:
To boxy73,

That is a Email confirmation msg box. Is not a popup

window.

The confirmation msg box is brought up by IE/Windows as

what elhy has mentioned.
0
 
boxy73Commented:
In that case don't use that confirm. Build your our confirm as a window.showModal....  and use it as I've told you. It would be easy, wouldn't it?
0
 
elhyCommented:
boxy73,

but this confirmation box cannot be prevented. windows activate it whenever browser auto send email out. This is one of the security feature of windows. I'm not sure if there are any option for you to disable, as far as i know, it can't be opt out.
0
 
cozyboiAuthor Commented:
yah i agree with elhy...

This have given me a great headache
0
 
webwomanCommented:
OF courese, if you didn't use mailto, but handled it on the server like a REAL form, you wouldn't have ANY of the problems you're having.

If you want to do this correctly, you CANNOT test it on your machine unless you have a webserver/SMTP set up. If you insist on trying to test it out locally WITHOUT that, you CANNOT do it correctly.

You DO realize that you have NO control over what you get? You might get an attachment with the querystring, a nice email, or nothing. You have NO WAY to know, and NO WAY to make the user send it, or keep them from changing it. Also, if there's no mail client installed, it WILL NOT WORK AT ALL. Use web based mail? Won't work. Use a proprietary mail client (like AOL)? Won't work. Don't send the mail because you don't know why it popped up? Won't work. And a lot of people will just get a BLANK mail window and won't do ANYTHING.
0
 
cozyboiAuthor Commented:
To webwomen:

so wat u i should do now? i would like to hear ur advice.
0
 
webwomanCommented:
Contact whoever hosts your site, and ask THEM. You can't do something that's not supported on the server, and they most likely already have something you can use.
0
 
elhyCommented:
Hmm....that requires other skills such as writing of CGI, Perl, ASP, Cold Fusion, ASP.NET, JSP etc (depending on what the server support).
0
 
Commodus2Commented:
I'd use PHP to mail. It is so easy... easy to install. free. so almost every host supports it. looks like c(++).
www.php.net
0
 
webwomanCommented:
If the hosting service already has something set up and installed, it takes NO skill other than following directions. And most will have something set up. Certainly it's a lot easier than what they've done so far (that hasn't worked).

Of course, unless you contact them and ask, you won't know.
0
 
jaysolomonCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: webwoman {http:#8109899}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 8
  • 5
  • 4
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now