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

Syntax for onChange in popup

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
0
0
GB
I want to tidy up a popup by having it submit onChange but I am unable to get the syntax right. I have seen similar examples of this but just cannot get it right.
Code:
my $SELLSTAT= $query->popup_menu(
	-name=>'sellstat',
	-values=> \@SellStats,
	-default=>$results[40],
	-onChange=>[red]'document.forms.pstat.submit()',[/red]);
The form is called 'pstat' and works ok with a submit button.
Am I on the right track and is this method reliable across all browsers?

Keith
 
isn't 'forms' an array in the DOM?
Code:
document.forms[0].NAME OF FIELD

or

document.forms[0].submit();



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Thanks
It may well be an array of the model but I cannot get the syntax right.
I have tried it every way up but can't get it to work.
When I search, I find many references to property not supported.
I have worked round it using individual submit buttons for this app but wondered if it is possible with a drop down list.

Keith
 
[0]
>but I am unable to get the syntax right
>-onChange=>'document.forms.pstat.submit()'
With form name properly formed, pstat is well-formed, it should work just fine. Hence, if there is error on the onchange handling, it should be due to other reason.

[0.1] Make sure pstat is the "name" attribute's value (not id or whatever other named attribute on the form element).
[tt] <form name="pstat" ...>[/tt]

[1] The form I would be much preferred for the reason of making it independent of the hard-scripted name of the form's name is this.
[tt] -onChange=>'[blue]this.form[/blue].submit()'[/tt]
as long as you want the "popup_menu" submit the form where it is the child thereof.

[1.1] [tt]document.forms[0].submit()[/tt]
as suggested should work as well as long as it just happens to be the first form in the document order.

ps: There is a spurious comma (,) in the posted lines after the =onchange=>'...'. It poses no special problem and is perfect acceptible to the engine, but it seems a typo all the same.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top