Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4763 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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.

Posted

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>';

Posted

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.

Posted

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>';

Posted

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>';

This topic is 4763 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.