Solved

Evaluate my program

Posted on 1997-10-02
3
239 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>
0
Comment
Question by:senthil021397
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
kollegov earned 100 total points
Comment Utility
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. :)

0
 

Author Comment

by:senthil021397
Comment Utility
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


0
 

Author Comment

by:senthil021397
Comment Utility
Still waiting for Solution
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now