[thelist] <input type="radio"...behaving strangely...

john corry john at neoncowboy.com
Tue Sep 4 15:45:21 CDT 2001

I'm working on a PHP script that will allow editing the contents of a MySQL

I have a column in the db that acts as a flag, if it's '1' I will display
that record, if it's '0' I will not.

I have a form for changing the fields in the db, one of the options is to
set that flag as '1' or '0'. I am using radio buttons, my php for generating
the radio buttons looks like this:

	  if ($prop_Active == 1){
	  $radio = "<input type=\"radio\" name\"prop_active\" value=\"1\" checked>
Yes, this property is active<br>\n";
	  $radio .=	"<input type=\"radio\" name=\"prop_active\" value=\"0\"> No,
this property is not active<br> \n";
	  	echo ($radio);
		} else {
	  $radio =	"<input type=\"radio\" name=\"prop_active\" value=\"0\" checked>
No, this property is not active<br> \n";			  $radio .= "<input
type=\"radio\" name\"prop_active\" value=\"1\"> Yes, this property is
		echo ($radio);

I want the state of the radio buttons to reflect the contents of the
database, hence the if/else. But the weird thing is this...if I specify one
of the inputs as checked, then the other input will not select...you click
on it an dit just turns grey and the other one stays selected. My O'reilly
HTML book says that should set its 'default' state to checked but allow it
to be changed. As a workaround, I tried removing the 'checked' to rely on
the browser to automatically check the first element in the group...but that
didn't work, it just displayed them both as empty.

Isn't that weird? How do I get it to behave the way I want it to?

John Corry

More information about the thelist mailing list