in reply to dynamic HTML pull down

Greetings all,
I am not entirely sure I understand the problem but here are my thoughts on how to get (according to my understanding) the desired results.
why not create the list once and assign it to a string, then use regex string replacement for your various values;
my $dd_country_str; unless(open(FILE, "<countries.txt")){ die "cannot read file"; }else{ $dd_country_str .= qq*<select name="countries">\n*; while(<FILE>){ if(/(.*):(.*)/i){ $dd_country_str .= qq*<option value="$1">$2</option>\n*; } } $dd_country_str .= qq*</select>\n*; close(FILE); } ###now call the dd_str you just built; my $first_dropdown = $dd_country_str; $first_dropdown =~ s/(value="$country_alias_you_want_selected")/$1 sel +ected="selected"/g; ###XHTML compliant print $first_dropdown; . . .
Is that what you are looking for? It seemed from your original post you were going to be using the same list of countries each time, so I just created the dropdown list in a string and reused that each time.
just a thought.
Also you do not need to specify a name for each option within your select. The name of the select is what will be passed and assigned the value of whatever option is selected.
-injunjoel

Replies are listed 'Best First'.
Re: Re: dynamic HTML pull down
by csuhockey3 (Curate) on Nov 05, 2003 at 03:39 UTC
    I like the idea of one string, I am going to use that regardless to try and clean up how I access the text file that has the region and email aliases. Right now the aliases are hashed when I search the .txt file every time (bad). I made things much to difficult for myself. Also with this, the params would be $param{$1,3,3..} right -- the 'name' is not necessary?
      Greetings again,
      Sorry for the lag in response... work.
      Im not sure about your $param{$1,3,3...} question I think I would need to see more of your script to address that.
      However the 'name' is not necessary part was in reference to the line in your original post:
      <option name="country" value="">-- Select a Country --</option>
      in which case you do not need to give this option tag a name attribute since it is contained within the <select name="country"> drop down list.
      peace and blessings,
      -injunjoel