creating a dynamic html select option with perl -
the default selected value database not displayed, checked html , not show selected value. can give me insight on went wrong. thanks
$selected_val = 'selected'; print "<select>"; if ($auto_flag eq 'y'){ $selected_val = 'selected'; }else{ $selected_val = ''; } if ($auto_flag eq 'n'){ $selected_val = 'selected'; }else{ $selected_val = ''; } print "<option value=\"y\" $selected_val >yes</option>"; print "<option value=\"n\" $selected_val >no</option>"; print "</select>";
you should using separate variable names y/n
my $selected_y = ''; $selected_n = ''; if ($auto_flag eq 'y'){ $selected_y = 'selected'; } elsif ($auto_flag eq 'n'){ $selected_n = 'selected'; } print "<option value=\"y\" $selected_y >yes</option>"; print "<option value=\"n\" $selected_n >no</option>";
Comments
Post a Comment