Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2004, 07:40 PM
Authorized User
 
Join Date: Jul 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question concerning use of "onsubmit"

If I use this code to call a javascript clientside routine, it works fine:
<FORM ACTION = "CheckLogin3.asp" METHOD="POST" onsubmit="return jscript_Rtn()">

How would I write a similar routine in VBScript? What is the proper syntax? This isn't working:
<FORM ACTION = "CheckLogin3.asp" METHOD="POST" onsubmit="VBscript_Rtn()">

Cmarek
__________________
Cmarek
 
Old July 12th, 2004, 07:54 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<FORM ACTION = "CheckLogin3.asp" METHOD="POST" onsubmit="vbscript:VBscript_Rtn()">


 
Old July 12th, 2004, 09:40 PM
Authorized User
 
Join Date: Jul 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I still can't get it to work. I get the Error:
a runtime error has occured
Line:8
Error: Type mismatch: 'VBscript_Rtn'

So again, here is my code in brief:
<%
Function VBscript_Rtn()
   VBscript_Rtn = False
End Function
%>
<FORM ACTION = "CheckLogin3.asp" METHOD="POST" onsubmit="vbscript:VBscript_Rtn()"> (this is line 8)

Cmarek
 
Old July 12th, 2004, 09:47 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You are attempting to run a server-side script with a client-side event.

Client-side cannot trigger server-side code, except for posting to another page. They cannot directly interact.

HTH,

Snib

<><
 
Old July 12th, 2004, 11:07 PM
Authorized User
 
Join Date: Jul 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OOOPs.. I am just a beginner you see...
So I have fixed that last issue..BUT..I still have a problem with control being passed to "CheckLogin3.asp" when I don't want it to be. How can I now make my client side code avoid passing to "CheckLogin3.asp" when VBscript_Rtn = False? (No doubt a syntax issue)


So again, here is my NEWEST code in brief:
<SCRIPT LANGUAGE=VBSCRIPT>
Function VBscript_Rtn()
VBscript_Rtn = False
End Function
</SCRIPT>

<FORM ACTION = "CheckLogin3.asp" METHOD="POST" onsubmit="vbscript:VBscript_Rtn()">


Cmarek
 
Old July 13th, 2004, 09:36 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

So you want it not to submit the form onsubmit? That makes no sense, unless I'm misunderstanding.

However, the code would look something like this, I believe:

<form action='CheckLogin3.asp' method='post' onsubmit='return false'>

HTH,

Snib

<><
 
Old July 13th, 2004, 09:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Cmarek,

Quote:
quote:How would I write a similar routine in VBScript? What is the proper syntax? This isn't working:
Can you explain on Why you would like to do that in VBScript and what you are trying to accomplish using VBscript there that cannot be done using Javascript?

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old July 13th, 2004, 08:40 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

hi,
  why r u doing in VBScript. Ok, if u want to do...

<form name="frm1" method="post" action="disp.asp">
<input type="text" name="t1"><input type="submit">
</form>


<script language="vbs">
function frm1_onsubmit()
    if frm1.t1.value="" then
        frm1_onsubmit=false
    end if
end function
</script>



 
Old July 14th, 2004, 04:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, as rajanikrishna had suggested, you had to use is that way. You cannot use that as you call a javascript function for the button's OnSubmit event. In VBScript it is different kind of approach.

Code:
<form METHOD="POST" ACTION="vbsample.asp" name="MyForm">
<input type="text" name="MyBox" size="10">
<input TYPE="submit" VALUE="Submit Info!" name="submit">
</Form>
Your VBScript function should have a name as either MyForm_OnSubmit OR submit_OnClick to have the validation code in it and remember not to forget RETURN TRUE/FALSE after validation to effect the form submit action.

You can also take a look at this page.
Client-Side Form Field Validation with VBScript and ASP

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old July 14th, 2004, 01:06 PM
Authorized User
 
Join Date: Jul 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok Ok thanks folks -

    The answer is in the last few responses. I was just curious if it was possible to write a client side validation routine in vbscript, now I know it is possible. Javascript is preferred since more browsers like Javascript.

Cmarek





Similar Threads
Thread Thread Starter Forum Replies Last Post
Question rannonharris Access VBA 2 September 26th, 2006 02:05 PM
i have a question about .... saeedos BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 September 10th, 2005 05:28 PM
use of onsubmit cjmarek BOOK: Beginning ASP 3.0 1 July 14th, 2004 04:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.