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!

CGI popup_menu default 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
0
0
GB
I hit this problem a while back and got round it by creating the drop down box in HTML. I am tidying the code up and would like to use the correct popup_menu syntax.

This is some test code to highlight the problem. The dropdown menu works fine but I cannot get the default value to display, it always displays the first value of the array, am I missing something?


Code:
my @AVALS = ("- Select -","one","two","three");
my $LoadedValue = "two";
my $part = 'choice';

my $DATAA= $query->popup_menu(
-name=>$part,
-values=> \@AVALS,
-default=> $LoadedValue);

Keith
 
Hi

Your sample code generates valid HTML and the browser correctly displays it with the [tt]option[/tt] "two" selected by default.

Are you sure your sample is relevant to your problem ?


Feherke.
 
Thanks for having a look.
The contents of the array are loaded from a text file and despite chomping each line I have somehoe managed to get a space on the end of each item.
I am re-writing the routine so I will be able to investigate a bit better when all is tidy.

Keith
 
The line ends of the text file contain a chr(10) and a chr(13).
Chomp removes the chr(10) but leaves the chr(13) in place.
I know I can end the line with a comma and split it but is there a simpler solution?

Keith
 
Hi

Keith said:
Chomp removes the chr(10) but leaves the chr(13) in place.
More precisely [tt]chomp[/tt] removes [tt]$/[/tt] ( [tt]$INPUT_RECORD_SEPARATOR[tt] ). So just set [/tt][navy]$/[/navy][teal]=[/teal][green]"\r\n"[/green][teal];[/teal][tt] before calling [/tt]chomp[/tt].

Feherke.
 
Thanks for the info on chomp.

Once I got the values right, all but one of the popup menus in my form worked. The non working one had 'type' as it's field name and the HTML didn't like it.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top