Skip to main content
Participant
May 31, 2006
Question

setting form attribute value with php

  • May 31, 2006
  • 1 reply
  • 184 views
i am having trouble setting the checked attribute value of a radio button based on the url parameter search. if search == all then checked == checked else checked == unchecked.

<input type="radio" name="search" value="all" checked="<?php if ($_GET["search"] == "all") { echo"checked";} else { echo"unchecked";} ?>" />

what am i doing wrong?
This topic has been closed for replies.

1 reply

Participating Frequently
June 1, 2006
This code should work

<input type="radio" name="search" value="all" <?php if ($_GET["search"] == "all") { echo "checked";} ?> />