×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

CGI popup_menu default

CGI popup_menu default

CGI popup_menu default

(OP)
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
www.studiosoft.co.uk

RE: CGI popup_menu default

Hi

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

Are you sure your sample is relevant to your problem ?
 

Feherke.

RE: CGI popup_menu default

(OP)
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
www.studiosoft.co.uk

RE: CGI popup_menu default

(OP)
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
www.studiosoft.co.uk

RE: CGI popup_menu default

Hi

Quote (Keith):

Chomp removes the chr(10) but leaves the chr(13) in place.
More precisely chomp removes $/ ( $INPUT_RECORD_SEPARATOR ). So just set $/="\r\n"; before calling chomp.

Feherke.

RE: CGI popup_menu default

(OP)
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
www.studiosoft.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close