• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 517
  • Last Modified:

call asp sub from javascript function

I'm using an onSubmit form function, and I need that function to call 3 asp sub routines. They're all on the same asp page, so it shouldn't be too hard, but I don't know how to do it. I've tried just calling them directly, but they don't run.

How do I call a same page asp sub-routine from a javascript function?
<form name="checkout_PP_LI_Hid"  onSubmit="local()" action=.../form>

<script type="text/javascript">
function local() {

email()
}
</script>

Open in new window

0
tommthumb
Asked:
tommthumb
1 Solution
 
Lee SavidgeCommented:
You can't. Javascript is clientside and ASP script is serverside. If you want to call them, you'd need to post the form back to the server and execute the functions based on values passed back.

Lee
0
 
tommthumbAuthor Commented:
Is there an asp equivalent of form onSubmit?
0
 
Umar Topia.Net Full Stack DeveloperCommented:
Use __doPostback() by providing unique id of the button
0
 
Ryan ChongCommented:
For asp, if you don't want to repost your form, the simpler way maybe is to use AJAX:

http://www.w3schools.com/ajax/default.asp
0
 
rg20Commented:
Theres no reason this shouldn't work
<form name="checkout_PP_LI_Hid"  onSubmit="local()" action="..."  </form>

<script type="text/javascript">
function local() {

email()
}
</script>

but you would have to send the form reference with it

Why not

<form name="checkout_PP_LI_Hid" action="..." >

<input type=button value=submit name=send  onSubmit="local()">
</form>

Checking the javascript during the submit process and not the form submit
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now