Making user's selection on dynamic selection box stick?

Discussion in 'PHP' started by wolfcry, Jan 8, 2012.

  1. #1
    Hey all,

    Been a while and I hope all is well with you all.

    I'm currently building a calculation application that creates, and uses, dynamic form fields such as selection boxes and radio created exclusively via PHP.

    What I'm having trouble with is remembering how to make it so the browser remembers the original selection when the form submits back to the original page (action = same_page.php).

    Now the value fields in the tags are already populated with dynamic data. How do I do this? I've tried using JavaScript but I must have been doing something wrong because it wasn't working.

    Here's a bit of code to help you see what I'm talking about:

    
    <?php
    
    echo '<select name="test">';
    
    for($i = 1; $i <= 10; $i++){
    
      echo '<option value=" '.$i.' ">'.$i.'</option>';
    
    }
    
    ?>
    
    
    Code (markup):
    I'm sure it's something simple that I'm forgetting but for the life of me, I can't figure it out :confused:

    Thanks all!
     
    wolfcry, Jan 8, 2012 IP
  2. wolfcry

    wolfcry Peon

    Messages:
    27
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Never mind, I figured it.
     
    wolfcry, Jan 8, 2012 IP