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

Renaming params 2

Status
Not open for further replies.

audiopro

Programmer
Joined
Apr 1, 2004
Messages
3,165
Location
GB
I am tidying up a script and I am replacing some HTML (which works) with these CGI commands.
The incoming param has a value and I want to replace its value with 'viewcal'. The word 'viewcal' is being printed before the drop down menu.
Please - Someone tell me what I am missing?
Code:
print $query->startform(-method=>'POST',
			-action=>'thatjob.cgi',
			-name=>'viewform');

print $query->param(-name=>'call',
			-value=>'viewcal');

print $query->popup_menu(-name=>'locs',
			-values=>\@LOCATIONS,
			-onChange=>'viewform.submit()');
print '</form>';
Is there a form end command instead of the HTML?

Keith
 
I do not understand what you are trying to do. There is an end form method/function: end_form()

you should really be using start_form() instead of startform()
which is the old but still supported name of the start_form function.


------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
$query->param() returns the value of the named param... since you're (re)setting the param to "viewcal", param() returns "viewcal"

So when you print $query->param, you print out what param() returns, hence why it prints "viewcal" to your page, and it prints it above the dropdown box because you told it to print there. ;-)

-------------
Cuvou.com | The NEW Kirsle.net
 
Kirsle
I guess I just got carried away with the print statements.

Kevin
I am working from O'Reilly's Perl in a nutshell which gives that version. Looks like I need to invest in some new manuals.

I have been trying numerous variations in order top get it to work but still can't get it to reset the value of call.
My latest code, resets 'call' to '', not 'viewcal'.
This code works if I set up 'call' in a hidden var but not as it is.
Code:
print $query->start_form(-method=>'POST',
	-action=>'thatjob.cgi',
	-name=>'viewform');

my @set_par = $query->param(-name=>'call',
	-value=>'viewcal');

print $query->popup_menu(-name=>'ski',
	-values=>\@SKILLS);

print $query->popup_menu(-name=>'locs',
	-values=>\@LOCATIONS,
	-onChange=>'viewform.submit()');
print $query->end_form();

Keith
 
I am still unclear what you want to do, but look into -override:

-override

A boolean, which, if true, forces the element to take on the value specified by -value, overriding the sticky behavior described earlier for the -no_sticky pragma.




------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
This html does the job but obviously needs tidying up.
Code:
print "<FORM METHOD='POST' ACTION='thatjob.cgi' ENCTYPE='application/x-[URL unfurl="true"]www-form-urlencoded'[/URL] NAME='viewskis'>\n";
print "<INPUT TYPE='hidden' NAME='call' VALUE='viewloc'>\n";
print "<SELECT NAME='ski'>\n";
for($x=0; $x<@SKILLS; ++$x){
	print "<OPTION  VALUE=";
	print "\"$SKILLS[$x]\"";
	print ">";
	print $SKILLS[$x];
	print "</OPTION>\n";
}

print "</SELECT><br>\n";
print "<SELECT NAME='locs' ONCHANGE='viewskis.submit()'>";
for($x=0; $x<@LOCATIONS; ++$x){
	print "<OPTION  VALUE=";
	print "\"$LOCATIONS[$x]\"";
	print ">";
	print $LOCATIONS[$x];
	print "</OPTION>\n";
}
print "</SELECT>";
print </form>\n";

Keith
 
Code:
foreach my $v (@SKILLS){
    print qq~<OPTION  VALUE="$v">$v</OPTION>\n~;
}

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top