0

I am populating the drop down menu from database. And when I submit the form I am getting empty string in selected option. Here's my code any help will be appreciated. I have selected the first option as default any help.

print "<br>Name: <select>";
while ( my ($name) = fetchrow_array() ) {
    if ($name eq "Somethinge") {
        print "<option value=\"$name\" selected>" . $name . "</option>\n";
    }else {
        print "<option value=\"$name\">" . $name . "</option>\n";
        }
}
print "</select>";

I am getting the value using below but its returning empty whatever I select.

my $Name = param('name');
mysteriousboy
  • 159
  • 1
  • 7
  • 20

1 Answers1

1

You are missing name="client_name" in the select tag.

You probably ought to be escaping the client name in the value attribute (though for United Dynacare it isn't necessary). Using a library to generate your HTML (for instance, CGI) would have helped with both of these things.

ysth
  • 96,171
  • 6
  • 121
  • 214
  • Can you explain little bit on using library to generate html since it is very slow. To populate 1000 options its taking me over 1 minute. – mysteriousboy Feb 26 '13 at 17:41
  • that's pretty weird. can you start a new question for that, showing what you are doing and explaining what you want for the output? – ysth Feb 26 '13 at 19:59