JScript function used for onSubmit in FORM 
Author Message
 JScript function used for onSubmit in FORM

I have created a FORM:
<FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
verifySurvey()">

If I create a function called verifySurvey in Javascript and return false,
the form does not go to submit.asp.  But, if I create a function called
verifySurvey in JScript and return false, the form still goes to submit.asp.

What am I doing wrong?

Here is the code for the function:
<SCRIPT LANGUAGE="JSCRIPT">
function verifySurvey()
{
    return(false);

Quote:
}

</SCRIPT>


Tue, 17 Dec 2002 03:00:00 GMT  
 JScript function used for onSubmit in FORM
Okay, the information I gave was not exactly accurate, here is the exact
code:


<%
    function verifySurvey()
    {
          return(false);
    }
%>
<HTML>
<HEAD>
<BODY>
<FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return

Quote:
> verifySurvey()">

<INPUT TYPE=SUBMIT VALUE="Submit Survey" ID=ButtonSubmit>
</FORM>
</BODY>
</HEAD>
</HTML>

When I click the submit button, it goes to submit.asp.

But if I change the code to look like this, everything works fine:

<SCRIPT language="JAVASCRIPT">
    function verifySurvey()
    {
          return(false);
    }
</SCRIPT>
<HTML>
<HEAD>
<BODY>
<FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return

Quote:
> verifySurvey()">

<INPUT TYPE=SUBMIT VALUE="Submit Survey" ID=ButtonSubmit>
</FORM>
</BODY>
</HEAD>
</HTML>

Now when I click Submit, it does not go to submit.asp.

I need to be able to access some JSCRIPT variables in the function, so I
need to be able to have this function in JSCRIPT, not JAVASCRIPT.

Any ideas?

Quote:
> I have created a FORM:
> <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> verifySurvey()">

> If I create a function called verifySurvey in Javascript and return false,
> the form does not go to submit.asp.  But, if I create a function called
> verifySurvey in JScript and return false, the form still goes to
submit.asp.

> What am I doing wrong?

> Here is the code for the function:
> <SCRIPT LANGUAGE="JSCRIPT">
> function verifySurvey()
> {
>     return(false);
> }
> </SCRIPT>



Tue, 17 Dec 2002 03:00:00 GMT  
 JScript function used for onSubmit in FORM
You are expecting to return false from an onsubmit event, and yet have the submit function? Return true, and the submit functions. This is expected behavior.

I have no idea why Javascript would do otherwise, except that you are running it AFTER a default language is defined as JScript. Returning 'undefined' as a string would evaluate to true.

Perhaps someone else will see this point better than I.

--
Mark L. Ferguson    Please reply in Newsgroup
marfer's notes for OE 5 > http://www.geocities.com/SiliconValley/Bay/6386/IE_ng_notes.htm

Quote:

> Okay, the information I gave was not exactly accurate, here is the exact
> code:


> <%
>     function verifySurvey()
>     {
>           return(false);
>     }
> %>
> <HTML>
> <HEAD>
> <BODY>
> <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > verifySurvey()">
> <INPUT TYPE=SUBMIT VALUE="Submit Survey" ID=ButtonSubmit>
> </FORM>
> </BODY>
> </HEAD>
> </HTML>

> When I click the submit button, it goes to submit.asp.

> But if I change the code to look like this, everything works fine:

> <SCRIPT language="JAVASCRIPT">
>     function verifySurvey()
>     {
>           return(false);
>     }
> </SCRIPT>
> <HTML>
> <HEAD>
> <BODY>
> <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > verifySurvey()">
> <INPUT TYPE=SUBMIT VALUE="Submit Survey" ID=ButtonSubmit>
> </FORM>
> </BODY>
> </HEAD>
> </HTML>

> Now when I click Submit, it does not go to submit.asp.

> I need to be able to access some JSCRIPT variables in the function, so I
> need to be able to have this function in JSCRIPT, not JAVASCRIPT.

> Any ideas?


> > I have created a FORM:
> > <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > verifySurvey()">

> > If I create a function called verifySurvey in Javascript and return false,
> > the form does not go to submit.asp.  But, if I create a function called
> > verifySurvey in JScript and return false, the form still goes to
> submit.asp.

> > What am I doing wrong?

> > Here is the code for the function:
> > <SCRIPT LANGUAGE="JSCRIPT">
> > function verifySurvey()
> > {
> >     return(false);
> > }
> > </SCRIPT>



Tue, 17 Dec 2002 03:00:00 GMT  
 JScript function used for onSubmit in FORM
Thanks for responding, I will try to make my problem a little bit clearer.

The verifySurvey will do much more than return true or false.  Right now I
am just trying to get it to work within JScript because JScript is how I
access
the database and I need to do some database reads before I can determine if
I should submit or not.

The onsubmit = return verifySurvey() works fine if I do the function in
JavaScript.  But if I do the function in JScript it does not work. (The
return false does nothing because the submit.asp file still opens).

So what I really need to be able to do is have onsubmit = return
verifySurvey() work for a verifySurvey function written in JScript, inside
my <% %> block, or be able to call a JScript function from within
Javascript.  I have been unsuccessful in both.



You are expecting to return false from an onsubmit event, and yet have the
submit function? Return true, and the submit functions. This is expected
behavior.

I have no idea why Javascript would do otherwise, except that you are
running it AFTER a default language is defined as JScript. Returning
'undefined' as a string would evaluate to true.

Perhaps someone else will see this point better than I.

--
Mark L. Ferguson    Please reply in Newsgroup
marfer's notes for OE 5 >
http://www.geocities.com/SiliconValley/Bay/6386/IE_ng_notes.htm

Quote:
> Okay, the information I gave was not exactly accurate, here is the exact
> code:


> <%
>     function verifySurvey()
>     {
>           return(false);
>     }
> %>
> <HTML>
> <HEAD>
> <BODY>
> <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > verifySurvey()">
> <INPUT TYPE=SUBMIT VALUE="Submit Survey" ID=ButtonSubmit>
> </FORM>
> </BODY>
> </HEAD>
> </HTML>

> When I click the submit button, it goes to submit.asp.

> But if I change the code to look like this, everything works fine:

> <SCRIPT language="JAVASCRIPT">
>     function verifySurvey()
>     {
>           return(false);
>     }
> </SCRIPT>
> <HTML>
> <HEAD>
> <BODY>
> <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > verifySurvey()">
> <INPUT TYPE=SUBMIT VALUE="Submit Survey" ID=ButtonSubmit>
> </FORM>
> </BODY>
> </HEAD>
> </HTML>

> Now when I click Submit, it does not go to submit.asp.

> I need to be able to access some JSCRIPT variables in the function, so I
> need to be able to have this function in JSCRIPT, not JAVASCRIPT.

> Any ideas?


> > I have created a FORM:
> > <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > verifySurvey()">

> > If I create a function called verifySurvey in Javascript and return
false,
> > the form does not go to submit.asp.  But, if I create a function called
> > verifySurvey in JScript and return false, the form still goes to
> submit.asp.

> > What am I doing wrong?

> > Here is the code for the function:
> > <SCRIPT LANGUAGE="JSCRIPT">
> > function verifySurvey()
> > {
> >     return(false);
> > }
> > </SCRIPT>



Tue, 17 Dec 2002 03:00:00 GMT  
 JScript function used for onSubmit in FORM
Jerry

The reason it's not working is because in your first example, your function
is only available at the server because you have it in the ASP delimiters
 <% %>). Try this, browse to your first example, then view the Source. Your
function won't be there, so your onsubmit is ignored.

Mark


Quote:
> Thanks for responding, I will try to make my problem a little bit clearer.

> The verifySurvey will do much more than return true or false.  Right now I
> am just trying to get it to work within JScript because JScript is how I
> access
> the database and I need to do some database reads before I can determine
if
> I should submit or not.

> The onsubmit = return verifySurvey() works fine if I do the function in
> JavaScript.  But if I do the function in JScript it does not work. (The
> return false does nothing because the submit.asp file still opens).

> So what I really need to be able to do is have onsubmit = return
> verifySurvey() work for a verifySurvey function written in JScript, inside
> my <% %> block, or be able to call a JScript function from within
> Javascript.  I have been unsuccessful in both.



> You are expecting to return false from an onsubmit event, and yet have the
> submit function? Return true, and the submit functions. This is expected
> behavior.

> I have no idea why Javascript would do otherwise, except that you are
> running it AFTER a default language is defined as JScript. Returning
> 'undefined' as a string would evaluate to true.

> Perhaps someone else will see this point better than I.

> --
> Mark L. Ferguson    Please reply in Newsgroup
> marfer's notes for OE 5 >
> http://www.geocities.com/SiliconValley/Bay/6386/IE_ng_notes.htm


> > Okay, the information I gave was not exactly accurate, here is the exact
> > code:


> > <%
> >     function verifySurvey()
> >     {
> >           return(false);
> >     }
> > %>
> > <HTML>
> > <HEAD>
> > <BODY>
> > <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > > verifySurvey()">
> > <INPUT TYPE=SUBMIT VALUE="Submit Survey" ID=ButtonSubmit>
> > </FORM>
> > </BODY>
> > </HEAD>
> > </HTML>

> > When I click the submit button, it goes to submit.asp.

> > But if I change the code to look like this, everything works fine:

> > <SCRIPT language="JAVASCRIPT">
> >     function verifySurvey()
> >     {
> >           return(false);
> >     }
> > </SCRIPT>
> > <HTML>
> > <HEAD>
> > <BODY>
> > <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > > verifySurvey()">
> > <INPUT TYPE=SUBMIT VALUE="Submit Survey" ID=ButtonSubmit>
> > </FORM>
> > </BODY>
> > </HEAD>
> > </HTML>

> > Now when I click Submit, it does not go to submit.asp.

> > I need to be able to access some JSCRIPT variables in the function, so I
> > need to be able to have this function in JSCRIPT, not JAVASCRIPT.

> > Any ideas?


> > > I have created a FORM:
> > > <FORM action="submit.asp" method="POST" name="myQuery"
onsubmit="return
> > > verifySurvey()">

> > > If I create a function called verifySurvey in Javascript and return
> false,
> > > the form does not go to submit.asp.  But, if I create a function
called
> > > verifySurvey in JScript and return false, the form still goes to
> > submit.asp.

> > > What am I doing wrong?

> > > Here is the code for the function:
> > > <SCRIPT LANGUAGE="JSCRIPT">
> > > function verifySurvey()
> > > {
> > >     return(false);
> > > }
> > > </SCRIPT>



Tue, 17 Dec 2002 03:00:00 GMT  
 JScript function used for onSubmit in FORM
Hi

The difference is not in JavaScript / JScript
but in client / server side thing


<%
Runs on server using the default lang set above
%>

<script language="VBScript" RUNAT="Server">
Some vbscript block here
</script>

<script type="text/JavaScript">
<script LANGUAGE="JavaScript">
Runs on client

etc..

--
--
Best Regards
   Vidar Petursson -
==============================
  Microsoft Internet, Client, SDK  MVP
==============================
Lead Client / Server / SQL programmer
 http://www.icysoft.com

 http://www.dna.is

 No matter where you go there you are.
==============================
--

Quote:
> Okay, the information I gave was not exactly accurate, here is the exact
> code:


> <%
>     function verifySurvey()
>     {
>           return(false);
>     }
> %>
> <HTML>
> <HEAD>
> <BODY>
> <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > verifySurvey()">
> <INPUT TYPE=SUBMIT VALUE="Submit Survey" ID=ButtonSubmit>
> </FORM>
> </BODY>
> </HEAD>
> </HTML>

> When I click the submit button, it goes to submit.asp.

> But if I change the code to look like this, everything works fine:

> <SCRIPT language="JAVASCRIPT">
>     function verifySurvey()
>     {
>           return(false);
>     }
> </SCRIPT>
> <HTML>
> <HEAD>
> <BODY>
> <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > verifySurvey()">
> <INPUT TYPE=SUBMIT VALUE="Submit Survey" ID=ButtonSubmit>
> </FORM>
> </BODY>
> </HEAD>
> </HTML>

> Now when I click Submit, it does not go to submit.asp.

> I need to be able to access some JSCRIPT variables in the function, so I
> need to be able to have this function in JSCRIPT, not JAVASCRIPT.

> Any ideas?


> > I have created a FORM:
> > <FORM action="submit.asp" method="POST" name="myQuery" onsubmit="return
> > verifySurvey()">

> > If I create a function called verifySurvey in Javascript and return
false,
> > the form does not go to submit.asp.  But, if I create a function called
> > verifySurvey in JScript and return false, the form still goes to
> submit.asp.

> > What am I doing wrong?

> > Here is the code for the function:
> > <SCRIPT LANGUAGE="JSCRIPT">
> > function verifySurvey()
> > {
> >     return(false);
> > }
> > </SCRIPT>



Wed, 18 Dec 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Using onsubmit from a form

2. Form onsubmit event from Form Tag

3. Why command onsubmit not function in JavaScript

4. onSubmit function not firing

5. ONSUBMIT FUNCTION

6. onsubmit function

7. Accessing form element in the event handler OnSubmit

8. OnSubmit event of Form object

9. Syntax for canceling a form submit in the onSubmit event

10. Calling an external VB function form jscript

11. how to handle NULL values from a FORM when using date string functions - help please

12. using variables inside a Response.Form() function

 

 
Powered by phpBB® Forum Software