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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -