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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submit() method using onChange handler

Status
Not open for further replies.

kangaloo1971

Programmer
Nov 28, 2001
4
US
I'm trying to change the display responding to the selected option in the selected box, and wrote the following code:

..<head><script language=&quot;JavaScript&quot;>
function selectGroup() {
document.formname.submit()
}
</script>..
..<form name=&quot;formname&quot;..>..
..<select name=&quot;group&quot; onChange=&quot;selectGroup( )&quot;>..

Whenever I try to change the display by selecting certain option, I get a message &quot;Object doesn't support this property or method.&quot; I tried several other things, including to change document.formname.submit() to this.form.submit(), which gave me a msg &quot;this.form is null or not an object.&quot;. Could anyone help me out to solve this problem?
 
Have you tried just putting the submit in the onChange event?

..<form name=&quot;formname&quot;..>..
..<select name=&quot;group&quot; onChange=&quot;document.formname.submit();&quot;>..

Mise Le Meas,

Mighty :)
 
Thank you for suggestion, Mighty.
I tried it, but still have got the &quot;Object doesn't support this property or method&quot; error message...
 
I thing that you must put the action too :


..<select name=&quot;group&quot; onchange=&quot;document.choix.action='Page.html'; document.choix.submit();&quot;>..

if not try to change that :

..<select name=&quot;group&quot; onChange=&quot;selectGroup( )&quot;>..

in

..<select name=&quot;group&quot; onChange=&quot;javascript selectGroup();&quot;>..
 
>>&quot;Object doesn't support this property or method.&quot;
on what string? from wich you are calling this function or on the function itself?

if it is in document.formname.submit() then its probably your fault:
check if your form really has name of formname or try document.forms.formname.submit()

Victor
 
I get &quot;Object doesn't support this property or method.&quot;on document.formname.submit(), as well as document.forms.formname.submit().

formname seems valid. I checked it using alert() method (instead of submit()) and got the correct field value via formname.

I kinda followed Daft69's suggestion to add action, by including document.formname.action = &quot;/display.pl&quot; in the function definition, but got the same error message.
 
post the form & the script here, please Victor
 
Do you have a button on your form named &quot;submit&quot;? This has been known to cause just the error you mentioned. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Yes, I had the button named &quot;submit&quot; and after removed it, everything worked beautifully!

I appreciate tsdragon + others for your wonderful advises.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top