Solved

OnSubmit  Post Problem

Posted on 1997-04-03
1
931 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 70 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

734 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