1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How do I verify if radio button is checked/ unchecked with PHP?

Discussion in 'PHP' started by username178452, Jul 1, 2008.

  1. #1
    I have two text boxes, box1 and box2, and two radio buttons, radio1 and radio2. Well, my intention is, if i check radio1, box2 becomes disabled, and if i check radio2, box1 become disabled. How to do that?
     
    username178452, Jul 1, 2008 IP
  2. King Goilio

    King Goilio Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    33
  3. Nafai

    Nafai Peon

    Messages:
    105
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That is clientside behavior you are describing, so you need to use javascript.

    Something like:
    
    <input type="radio" id="r1" onclick="enable(1);" /><input type="text" id="t1" /><br />
    <input type="radio" id="r2" onclick="enable(2);" /><input type="text" id="t2" /><br />
    <script type="text/javascript">
    function enable(n){
      for (var i=1;i<=2;i++){
        document.getElementById('t'+i).disabled = (i!=n);
      }
    }
    </script>
    
    Code (markup):
     
    Nafai, Jul 1, 2008 IP