sandari Posted December 15, 2012 Share Posted December 15, 2012 <p><p>What is wrong with this code? <?php $Available=1; ... <label>Currently Available?</label><br /> <input type=\"radio\" name=\"Available\" value=(if($Available==1){echo'checked=\"checked\"'})>Yes <input type=\"radio\" name=\"Available\" value=(if($Available!=1){echo'checked=\"checked\"'})>No ?> Whatever I do I cannot get any value to display in either option. Link to comment Share on other sites More sharing options...
HartleySan Posted December 15, 2012 Share Posted December 15, 2012 You're mixing PHP code and HTML code. Where're your echo statements? Are you not getting any errors? 1 Link to comment Share on other sites More sharing options...
sandari Posted December 17, 2012 Author Share Posted December 17, 2012 Sorry, code should read: <?php $Available=1; echo "<label>Currently Available?</label><br /> <input type=\"radio\" name=\"Available\" value=(if($Available==1){echo'checked=\"checked\"'})>Yes <input type=\"radio\" name=\"Available\" value=(if($Available!=1){echo'checked=\"checked\"'})>No"; ?> Link to comment Share on other sites More sharing options...
margaux Posted December 17, 2012 Share Posted December 17, 2012 Checked is an attritbute of input type so it should not be within the value attribute. I think this is what you are trying to do <form method="post" action="#"> <label>Currently Available?</label><br /> <input type="radio" name="Available" value="Yes" <?php if (isset($_POST['Available']) && $_POST['Available'] == "Yes") echo 'checked="checked"';?>>Yes <input type="radio" name="Available" value="No" <?php if (isset($_POST['Available']) && $_POST['Available'] == "No") echo 'checked="checked"';?>>No <input type="submit" name="submit" value="Submit"> </form> 1 Link to comment Share on other sites More sharing options...
sandari Posted December 24, 2012 Author Share Posted December 24, 2012 Thank you. This works very well. Link to comment Share on other sites More sharing options...
Recommended Posts