Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OnSubmit  Post Problem

Posted on 1997-04-03
1
Medium Priority
?
935 Views
Last Modified: 2012-08-14
Ok,

Here's the problem.  I am submitting form responses into a database. I am using the OnSubmit Handler and the POST form method.  I call the function (Save It () ) on the form submission.  The posting of the data goes through (because I get returned info from the database) but it will not recognize the form name ( Srch ).  It says Srch not defined.

My question is... Can you use POST and OnSubmit in this manner.  If not how do you go about doing these two things at once ??

Here are the Snippets of code......

-----------------------(The Function)----------------------

<Script Language="javascript">
<!-- Hide it
      function SaveIt ()
        {
        if (Srch.Skills.value.length != 0)
                                           {
        var expdate = new Date ();
        expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000));
        SetCookie('Skills',Srch.Skills.value, expdate);
        SetCookie('Phone',Srch.Location.value, expdate);
       SetCookie('Travel_Location',Srch.Travel_Location.value,
expdate);
                                                }
          else
             {
                 alert('You left a field blank.');
                 return false;
             }
         }
// done -->    
</script>

-----------------------(The Code)-------------------------

<form name="Srch" OnSubmit="SaveIt ()" Method="POST" ACTION="http://206.201.123.139/scripts/acc2web.exe">
<FONT FACE="ARIAL,HELVETICA" SIZE="+1">
<CENTER><Table border="3"><td><IMG SRC="fire3.gif"></td></table>
<br>
<br>
</center>
<H2><u>Query Information Area</u></H2>
<br>
<font size="+0">My <i>ideal</i> candidate would....<br><br>
<TABLE BORDER="0">
<TR>
<td align="left">
<INPUT TYPE="hidden" NAME="DbName" VALUE="c:\Webshare\wwwroot\iteam\database\person.mdb">
Have the following skills :
</td>
<td align="left">
<INPUT TYPE=text SIZE=24 NAME="Skills">
---------------------------(End)-------------------------

Thanks !!!!
0
Comment
Question by:dmccarty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
RM032397 earned 140 total points
ID: 1265118
The form name in SaveIt is not enough to define the form which must be window.document.Srch
The short way is to pass a parameter. For onClick and such in INPUTs it would be this.form but for onSubmit, because it is in the FORM tag 'this' will suffice (and equates automatically to window.document.Srch), hence

<form name="Srch" OnSubmit="SaveIt(this)"

Then you can receive the parameter as

function SaveIt(form) {

and within the function ...

 if (form.Skills.value.length != 0)
 
... so all the elements are fully defined objects.

onSubmit functions are independent of SUBMIT, they just happen when the form is submitted. Your js function is failing, while the SUBMIT itself is succeeding. It will not take too long to have it zinging along I hope!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

609 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