Forum Moderators: coopster

Message Too Old, No Replies

Keep Radio Buttons Checked

         

matthewamzn

6:03 am on Aug 24, 2006 (gmt 0)

10+ Year Member



I have a form that visitors fill out and submit (checking some radio buttons). The form is then displayed again, with search results below it. How can I keep the radio buttons checked (so users don't have to recheck them during each search)?

dreamcatcher

7:22 am on Aug 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<input type="radio" name="button" value="Something"<?php echo isset($_POST['button'] && $_POST['button']=='Something'? ' checked' : '';?>>

dc

eelixduppy

3:17 pm on Aug 24, 2006 (gmt 0)



Just missing a parenthesis, dc:

<input type="radio" name="button" value="Something"<?php echo isset($_POST['button'][b])[/b] && $_POST['button']=='Something'? ' checked' : '';?>>

;)

henry0

3:23 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On the same topic wouldn't you include within that closing parenthesis the && section
:)

eelixduppy

3:32 pm on Aug 24, 2006 (gmt 0)



Actually, henry0, you wouldn't want to include that part within the isset function. I think what you mean is something like this, however, with a quick test, you can see that these surrounding parenthesis are not needed:

<input type="radio" name="button" value="Something"<?php echo [b]([/b]isset($_POST['button']) && $_POST['button']=='Something'[b])[/b]? ' checked' : '';?>>

henry0

5:13 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes that is what I had in mind
when I use && with isset or isempty () or both I always keep both of the components within the parenthesis.

dreamcatcher

6:00 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just missing a parenthesis, dc:

Thanks eelixduppy. :)