470,636 Members | 1,610 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

submit question

When the user click the submit button in myform.asp, then it will
invoke the
javascript to check the form data. I want to know if we need
document.myform.submit(); ?? Because even I comment it out,
formresponse.asp
could still get the form data.

//myform.asp
<script type="text/javascript">
function checkformdata()
{ //etc...
document.myform.submit();
}
</script>

<form name="myform" action="formresponse.asp" method="post"
onsubmit="checkformdata()">
//controls etc...
</form>

//formresponse.asp
<%= Request.Form %>
Jul 23 '05 #1
3 1309
In article <ba*************************@posting.google.com> , Matt
says...
When the user click the submit button in myform.asp, then it will
invoke the
javascript to check the form data. I want to know if we need
document.myform.submit(); ?? Because even I comment it out,
formresponse.asp
could still get the form data.


Didn't you multi-post this to alt.html? Naughty boy.

--
Hywel I do not eat quiche
http://kibo.org.uk/
http://kibo.org.uk/mfaq.php
Jul 23 '05 #2
In article <ba*************************@posting.google.com> ,
jr********@hotmail.com enlightened us with...
When the user click the submit button in myform.asp, then it will
invoke the
javascript to check the form data. I want to know if we need
document.myform.submit();


No; it's redundant in the code you posted.
Remove it.

--
--
~kaeli~
You feel stuck with your debt if you can't budge it.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3
Matt wrote:
When the user click the submit button in myform.asp, then it will
invoke the
javascript to check the form data. I want to know if we need
document.myform.submit(); ?? Because even I comment it out,
formresponse.asp
could still get the form data.

//myform.asp
<script type="text/javascript">
function checkformdata()
{ //etc...
document.myform.submit();
}
</script>

<form name="myform" action="formresponse.asp" method="post"
onsubmit="checkformdata()">
//controls etc...
</form>

//formresponse.asp
<%= Request.Form %>


Using submit() is only for when you want to submit something through a
different means. Say, for instance, you want an anchor link to submit a
form. You can set onClick="document.myform.submit()".

When the onSubmit callback is called, it is called either because
someone pressed the submit button, or submit() was called.

Note that you should return something from your function, and return it
to the onSubmit handler. Returning true tells the form to keep going,
but returning false tells the form not to send. For instance, you might
do something like this:

<script type="text/javascript">
function checkFormData()
{
// etc...
if(dataValid)
return true;
else
{
alert("You are a naughty boy");
return false;
}
}

<FORM ... onSubmit="return checkFormData()">

Brian

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by shake | last post: by
6 posts views Thread by CJM | last post: by
4 posts views Thread by actionwoman63 | last post: by
5 posts views Thread by Pascal Batzli Jr | last post: by
26 posts views Thread by Mica Cooper | last post: by
7 posts views Thread by David T. Ashley | last post: by
1 post views Thread by Korara | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.