hi :icon_neutral: ,

I want to make a radio button checked if the form is already submitted. The form and output are on the same page. I have 2 (later more) radio buttons and i want the form to 'remember' the state of the button, e.g. insert a checked="checked" text in the form.

I tried 36 variations on this code:

<p><input name="cref" type="radio" value="http://games.allemaal.info/context-g4g-nl.xml" 
	 <?php if ($_GET["cref"]=="http://games.allemaal.info/context-g4g-nl.xml") echo "checked="checked""; ?>/> Google for Games</p>

I keep getting syntax errors.
Any help appreciated :icon_confused:

nevermind, i needed to escape the quotes.

nevermind, i needed to escape the quotes.

Hi I have the same problem. I tried to escape quotes but still doesn't work. Do u mind posting the changed code? Thanks.

Hi I have the same problem. I tried to escape quotes but still doesn't work. Do u mind posting the changed code? Thanks.

Sure, here you go:

<!--	  now, the radio buttons need to remember the state they where in, so the user doesn't have to click the radio button everytime they do a new search-->
	  
     <p><input name="cref" type="radio" value="http://games.allemaal.info/context-g4g-nl.xml" 
	 <?php if ($_GET["cref"]=="http://games.allemaal.info/context-g4g-nl.xml") echo "checked=\"checked\""; ?>/> 
     Free online games</p>
	  <p> <input name="cref" type="radio" value="http://games.allemaal.info/context-g4g-nl-wow.xml"
	  <?php if ($_GET["cref"]=="http://games.allemaal.info/context-g4g-nl-wow.xml") echo "checked=\"checked\""; ?> />	
	  World of Warcraft</p>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.