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

Setting Perl CGI param() with Javascript

Status
Not open for further replies.

sjeps

Programmer
Jan 31, 2008
4
IT
Hi everyone.
I have a Perl- GCI dinamic page.
The page have a single form with some submit buttons.
Each button is named 'action' but have different values (such 'cancel' 'save' 'open'). Pressing a button i reload the page and test wich button was pressed by testing the parameter 'action':

if(param('action')...

and i do something.

Now the problem is: i have a selection menu (popup_menu) and i want to do the same thing with it.
I mean, when i change selected item i want to change 'action' (f.e. to 'Select' not to the single item selected) to handle it the usual way.

I'm trying with javascript and OnChange event, but i really can't get how to change that damn param('action') with javascript.

Every tip is welcome, thanks.
 
param('action') just comes from the variable named 'action' as it got submitted to the CGI script.

Example...

Code:
<form name="myform" action="something.cgi" method="post">

<input type="hidden" name="action" value="cancel">

<select name="option" onChange="document.myform.action.value = this.value; document.myform.submit()">
<option value="cancel">Cancel</option>
<option value="open">Open</option>
<option value="save">Save</option>
</select>

That would update the value of the hidden field 'action' with the current value of the select box. But if you were doing that, you could just have the select box be named 'action' and have it just submit the form onChange.

-------------
Cuvou.com | My personal homepage
Project Fearless | My web blog
 
I had already tried something like this:

popup_menu(-name=>'listaesa',
-values=>\@listaesa,
-default=>$esame[2],
-override=>1,
-OnChange=>"document.mainform.action.value='Sel';document.mainform.submit();"
)

(the pop_menu is in mainform)

But when i click on another name on the menu the page is reloaded but param('action') it's empty..

Maybe the problem is that there are a lot of objects (submit buttons) named 'action'?

I also tried adding an hidden element called 'action' but it doesn't worked anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top