Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript 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 October 18th, 2004, 07:16 AM
Authorized User
 
Join Date: Sep 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Form Submit Problem.

In my form, I have a button called "Search". When user clicks on this button, a small pop-up window will appear. The codes are as below:

Code:
<script language="JavaScript" type="text/javascript">

function doLookup() {
  // pop-up window
}

function checkForm() {
  alert("Check Form");
  return true;
}

</script>

<form name="form" method="post" onSubmit()="return checkForm();">
 <tr>
  <td><input type="image" name="searchBtn" onClick="lookUp();return false"></td>
 </tr>
</form>
The pop-up window will display a list of student name. When user selects a name and clicks "OK" button. The page will call a javascript function to submit opener's form and closes the pop-up window. The script are as below:

Code:
function submitForm() {
   opener.document.form.submit();
   opener.focus();
   window.close();
}
What I don't understand is after the pop-up window has been closed, the form did submit. But why I can't see an alert message pop-up?

I would like to apologize if my explanation is confusing. And I would try my best to explain it if requested.

Thanks in advanced.

 
Old October 18th, 2004, 08:30 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You're using onSubmit() when you should be using onsubmit, notice the lack of parenthesis (), and the lowercase.

HTH!

-Snib <><
Try new FreshView 0.2!
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
 
Old October 19th, 2004, 01:04 AM
Authorized User
 
Join Date: Sep 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for late reply. I have try both method of onSubmit and onsubmit without (), but it still doesn't work.

 
Old October 19th, 2004, 03:15 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I don't think you need the return keyword in there.

Your form tag should look like this:

<form name="form" method="post" onsubmit="checkForm()">

Does it?

-Snib <><
Try new FreshView 0.2!
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
 
Old October 20th, 2004, 09:19 AM
Authorized User
 
Join Date: Sep 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have try the method "onSubmit = checkForm()", but still it doestn't work. It seems that method "checkForm()" is not being invoked.

Anyway, thanks for reply.

 
Old October 20th, 2004, 09:39 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi muklee,

"onSubmit = checkForm()" is correct, but when you submit a form using code e.g. myForm.submit();, the forms onsubmit event is not fired.

You could create a submit button for your form & use style="display: none" to hide it, then call it's click method to trigger the onsubmit or do something like
Code:
if(opener.checkForm()){
    opener.document.form[0].submit();
}
HTH,

Chris

 
Old October 20th, 2004, 12:10 PM
Authorized User
 
Join Date: Sep 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot guys. I finally figure out what's the reason now.

 
Old May 27th, 2007, 10:06 PM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey guys..


If i want to display data automatically in one field when related data is chosen in a dropdown menu, is it possible to use document.form.submit?

as in- say in the database, there are two columns
Name | Age

In my form, i have a dropdown menu of names extracted from the database using asp. And i want the age corresponding to the name to appear when i select a particular name. but i dont want to submit the form because there are other values that need to be keyed-in before the form is submitted using a submit button.
If i use document.form.submit, the age appears when i select the name but the entire form is submitted.
Anyway of stopping a form from submitting.. like stop command or something?

Or any other way of auto appearing the age at the selection of the name aside document.form.submit?
I have tried onclick/onselect.. doesnt work.





Similar Threads
Thread Thread Starter Forum Replies Last Post
WebRequest/WebResponse form submit problem. HELP! MAtkins ASP.NET 1.0 and 1.1 Professional 2 December 23rd, 2010 12:28 AM
form submit problem alexscan Beginning PHP 0 January 1st, 2008 08:37 PM
form submit problem/dependent list menus alexscan Pro PHP 0 January 1st, 2008 06:29 PM
Firefox Problem - submit form mattastic Javascript How-To 4 July 19th, 2005 07:30 AM
form submit problem dhaywirex Javascript How-To 2 March 29th, 2004 05:27 AM





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