开发者

php html retain selected field value after form submit

I'm trying to choos开发者_运维问答e a selection from a drop down list and submit the value with POST, set the value to a variable when the page reloads, and set the drop down list to the previously selected value but it is not working. Here is my code:

<?php
  $BoardSide = isset( $_POST['BoardSide'] ) ? $_POST['BoardSide'] : 0 ;
?>
<html>
    <body>
      <form method="POST" action="?" name="inputform1">
           <select name="BoardSide" style="width:80px;">
               <option value="0" <?php $BoardSide == 0 ? 'selected' : '' ?> >None</option>
                <option value="1" <?php $BoardSide == 1 ? 'selected' : '' ?> >Top</option>
                <option value="2" <?php $BoardSide == 2 ? 'selected' : '' ?> >Bottom</option>
           </select>
      </form>
    </body>
</html>


Do you mean:

<?php echo $BoardSide == 0 ? 'selected' : '' ?>

Without that echoyou are not outputting anything there it seems ?


Did you check the HTML generated source ? Seems to me you don't "echo" anything back.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜