We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Evaluate my program

senthil021397
on
Medium Priority
303 Views
Last Modified: 2011-09-20
Please evaluate my Javascript program which collects all the form inputs and mails to a email account. My users have various versions of Netscape and some of them have the warning message box which comes off before submitting a form. My problem is, if the user waits for a few more seconds than the timeout period to hit OK in the warning box, then the program doesn't work.

Is there a solution to fix this problem. Also, I am able to disable the Form Submit Warning box in Netscape 3.0 and am not able to do that in Netscape Communicator 4.02
=====================================================
<HTML>

<HEAD><TITLE>MSP Systems Feedback Form</TITLE>

<SCRIPT>

function response()

      {
          location.href="http://msp03.msp.sc.ti.com/";
      }

</SCRIPT>


<SCRIPT LANGUAGE="JavaScript">
<!--

function mailIt(form) {
  var data = document.dataForm
  var userInfo = ""

  form.action += "?subject=" + data.subject.value
  userInfo += "Page Title:  " + document.title + "\n"
  userInfo += "Mailed From: " + document.location + "\n\n"
  form.mailBody.value = userInfo + data.body.value
  location.href="http://msp03.msp.sc.ti.com/";
  return true
}
// -->
</SCRIPT>



</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT=navy LINK=red VLINK=red>

<center>
<TABLE BORDER=3 CELLSPACING=5  width=600>
<tr>
<th><a href="/index.html"><FONT COLOR="black">MSP Business Systems</a></th>
<th><a href="/reports.html"><FONT COLOR="black">MSP Reports Home</a></th>
</tr>
</TABLE>
</center>
<CENTER>

<TABLE>
<FORM NAME="dataForm">
  <TR>
  <TH ALIGN=right>Name:
  <TD><INPUT NAME="name" SIZE=40 >
 </TR>


 <!-- DELETE THIS TABLE ROW IF YOU'RE HARDCODING A SUBJECT -->
 <TR>
  <TH ALIGN=right>Subject:
  <TD><INPUT NAME="subject" SIZE=40>
 </TR>
 
 <TR>
  <TH ALIGN=right VALIGN=top>Message:
  <TD><TEXTAREA NAME="body" COLS=60 ROWS=10 WRAP=virtual></TEXTAREA>
 </TR>
</FORM>

<FORM
  NAME="mailForm"
  ACTION="mailto:senthil@ti.com"
  METHOD="post"
  ENCTYPE="multipart/form-data"
  onSubmit="return mailIt(this)">
<INPUT TYPE="hidden" NAME="mailBody" VALUE="">
 <TR>
  <TD COLSPAN=2 ALIGN=center>
    <INPUT TYPE="submit" VALUE="Send This Mail Message Now" onClick='setTimeout("response()",2000)'>
</TR>
</FORM>
</TABLE>
<p>
<p>

<center><nobr><A HREF="http://www.ti.com/sc/docs/schome.htm"><IMG SRC="/OWS-IMG/scnv1.gif" ALT="Semiconductors" border=0></a><A HREF="http://www.ti.com/sc/docs/msp/msphome.htm"><IMG SRC="/OWS-IMG/scnvmsp.gif" ALT="Mixed Signal and Analog" border=0></A><A HREF="http://www.ti.com/sc/docs/search.htm"><IMG SRC="/OWS-IMG/mpsernav.gif"  border=0 ALT="Search"></A><A HREF="/sc/docs/feedback.htm"><IMG SRC="/OWS-IMG/feednav.gif"  border=0 ALT="Feedback"></A><A HREF="http://www.ti.com/corp/docs/home.htm"><IMG SRC="/OWS-IMG/tihmnav.gif"  border=0 ALT="TI Home"></A></nobr><BR></center>



<ADDRESS>

<CENTER>

<A HREF="http://www.ti.com/corp/docs/copyrght.htm">(c) Copyright</A> 1997 Texas Instruments Incorporated. All rights reserved. <BR>



<p>
<center><IMG SRC="/OWS-IMG/owsdr.gif"></center>



</CENTER>

</ADDRESS>


<CENTER>
<script language="JavaScript">
<!--
      document.write("Updated " + document.lastModified);
// -->
</script>

</CENTER>


</BODY>

</HTML>
Comment
Watch Question

Commented:
Solution is easy:
You can set some semaphore variable to true
in function submitting e-mail
let it be declared as

var semaphore=null

so in function mailit()
add single row before return:

semaphore=true;

function response than can be modified:


      function response()

      { if(semaphore)
         {if(semaphore==true)
           {setTimeout('location.href="http://msp03.msp.sc.ti.com/',500}
         }
        else
         setTimeout("response()",100)
      }

Thus this function will be called recursevly each 100ms
And check was the form submited or not, if it is already submited it will set 500ms timeout for submission and change location.

You now do not need 2sec timout onClick, make it 100ms. :)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Kollegov,

One part of solution seems to work, Even with the Warning box enabled, the browser is still holding the data till i click OK. It doens'nt matter how long i wait. BUT, after clicking OK, location.href="http....." doesn't seem to work. It stays in the same page.
I tried a few things without success. Any thoughts..

Senthil


Author

Commented:
Still waiting for Solution
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.