Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with onchange submit() event

Status
Not open for further replies.

milo3169

Programmer
May 2, 2007
42
Hi,

I'm trying to setup an event to submit this form when I do an onchange from a drop down list.

First I created the list dynamically with PHP, but when I do an onchange it comes up with an error saying - document.form1 has no properties. Any idea on why this is coming up with that error? Is it because of the dynamic list?

Code:
      	<form method="post" action="sub_cat_menu.php" name="form1" >
      	<select class="formfield" name="item_code" onchange="form1.submit()">
       		<?php echo build_dropdown(); ?>
      	</select>
      	</form>
 
Hi

Code:
<select class="formfield" name="item_code" onchange="[red]document.[/red]form1.submit()">

[gray]// or[/gray]

<select class="formfield" name="item_code" onchange="[red]this.form[/red].submit()">

Feherke.
 
I've tried it and it submits the other form in the document that's why I specified the form name. I forgot to mention that it is a form within a form. Is that what is causing the problem?
 
ensure your forms are properly formed. do they have closing tags? make sure they're not nested. does your website pass validation?

short of all that, try

document.forms['YourFormName'].submit();

also, make sure you don't have a field named "submit".



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top