grumbachr Posted October 25, 2011 Posted October 25, 2011 I'm struggling with making a form I am working with sticky. I have everything working just as I'd like and submitting to Filemaker, I just need to make the radio buttons sticky. I am missing something, in the syntax and it has me stumped. I anyone can point me in the right direction it would be greatly appreciated. This line works. $html .= '<td width="25%" align="center"><input type="radio" name="regcheckin" value="Poor" /> </td>'; This line does not work. $html .= '<td width="25%" align="center"><input type="radio" name="regcheckin" value="Poor"' if ($_POST['regcheckin'] == 'Poor') echo'checked="checked"'' /> </td>'; I'd like the second line to work if possible.
doughemi Posted October 26, 2011 Posted October 26, 2011 Here is how I'd do it: if ($_POST['regcheckin'] == 'Poor'){ $checkedval =' checked="checked" '};//note the spaces before and after the text! } else { $checkedval = '': } $html .= '<td width="25%" align="center"><input type="radio" name="regcheckin" value="Poor"'. $checkedval .' /> </td>';
Genx Posted October 30, 2011 Posted October 30, 2011 Syntax looks fine. I'd suggest you debug what's actually getting posted... at the top of your form processing page (presumably this page), chuck in a print_r($_POST); and take a look at the output From the code you've pasted above, in the second example you have [value="Poor"'] - there's an extra quote there - might be breaking your post content.
webko Posted October 31, 2011 Posted October 31, 2011 The syntax in the original second example isn't really OK, as it has an invalid If statement in the middle of it... The first suggestion looks good, or you could do something like: $html .= '<td width="25%" align="center"><input type="radio" name="regcheckin" value="Poor"'; if ($_POST['regcheckin'] == 'Poor') { $html .='checked="checked"' } $html .=' /> </td>';
grumbachr Posted October 31, 2011 Author Posted October 31, 2011 Thank for the help everyone. This is the code I got working. I need to do more reading on how spacing impacts the code. I was really hoping to get it all on one line but it took a few. $html .= '<td width="25%" align="center"><input type="radio" name="regcheckin" value="Poor"'; if($_POST['regcheckin'] == 'Poor'){ $html .= 'checked="checked"';} $html .= ' /> </td>';
Recommended Posts
This topic is 5028 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now