make a radio button checked if it was selected before

Reply

Join Date: Nov 2008
Posts: 3
Reputation: dizid is an unknown quantity at this point 
Solved Threads: 0
dizid dizid is offline Offline
Newbie Poster

make a radio button checked if it was selected before

 
0
  #1
Nov 6th, 2008
hi ,

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:
  1.  
  2. <p><input name="cref" type="radio" value="http://games.allemaal.info/context-g4g-nl.xml"
  3. <?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
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 3
Reputation: dizid is an unknown quantity at this point 
Solved Threads: 0
dizid dizid is offline Offline
Newbie Poster

Re: make a radio button checked if it was selected before

 
0
  #2
Nov 6th, 2008
nevermind, i needed to escape the quotes.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 1
Reputation: newtotrade is an unknown quantity at this point 
Solved Threads: 0
newtotrade newtotrade is offline Offline
Newbie Poster

Re: make a radio button checked if it was selected before

 
0
  #3
Nov 29th, 2008
Originally Posted by dizid View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 3
Reputation: dizid is an unknown quantity at this point 
Solved Threads: 0
dizid dizid is offline Offline
Newbie Poster

Re: make a radio button checked if it was selected before

 
0
  #4
Nov 29th, 2008
Originally Posted by newtotrade View Post
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:

  1. <!-- 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-->
  2.  
  3. <p><input name="cref" type="radio" value="http://games.allemaal.info/context-g4g-nl.xml"
  4. <?php if ($_GET["cref"]=="http://games.allemaal.info/context-g4g-nl.xml") echo "checked=\"checked\""; ?>/>
  5. Free online games</p>
  6. <p> <input name="cref" type="radio" value="http://games.allemaal.info/context-g4g-nl-wow.xml"
  7. <?php if ($_GET["cref"]=="http://games.allemaal.info/context-g4g-nl-wow.xml") echo "checked=\"checked\""; ?> />
  8. World of Warcraft</p>
  9.  
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 4173 | Replies: 3
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC