Results 1 to 3 of 3

Thread: Check box-- make it so only one box can be checked?

  1. #1
    Join Date
    Aug 2006
    Posts
    65
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Check box-- make it so only one box can be checked?

    I need to be able to only check one box for each question.. there is 3 choices for each questions but you can only select one of them... I cant seem to find out how to do this.. I tried to google it but I couldnt find an answer.. It has to be something simple

    here are some of the questions
    Code:
    <tr><td> Phone Number:</td><td align="right"><input type="checkbox" name="GetPhone" value="Yes"> YES <input type="checkbox" name="GetPhone2" value="NO"> NO 
    		<input type="checkbox" name="GetPhone3" value="NA" checked="checked"> NA</td></tr>
    		
    	<tr><td> Email Address:</td><td align="right"><input type="checkbox" name="GetEmail" value="Yes"> YES <input type="checkbox" name="GetEmail2" value="NO"> NO 
    		<input type="checkbox" name="GetEmail3" value="NA" checked="checked"> NA</td></tr>
    	
    	<tr><td> IP Address:</td><td align="right"><input type="checkbox" name="GetIP" value="Yes"> YES <input type="checkbox" name="GetIP2" value="NO"> NO 
    		<input type="checkbox" name="GetIP3" value="NA" checked="checked"> NA</td></tr>

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Humper
    I need to be able to only check one box for each question..
    Then use the right tool: radio buttons.

    <td align="right">
    Use CSS (the text-align property, in this case), rather than the align attribute. Presentational markup should be avoided; those days are gone.

    <input type="checkbox" name="GetPhone" value="Yes"> YES <input type="checkbox" name="GetPhone2" value="NO"> NO
    <input type="checkbox" name="GetPhone3" value="NA" checked="checked"> NA
    Change the type attribute value to "radio", and give each radio button the same name. You should also use the label element to associate each label with the appropriate control. For example:

    HTML Code:
    <label><input type="radio" name="GetPhone" value="Yes"> YES</label>
    <label><input type="radio" name="GetPhone" value="NO"> NO</label>
    <label><input type="radio" name="GetPhone" value="NA" checked> NA</label>
    A final note illustrated above: don't include the attribute value for boolean attributes like checked and selected. Just use the attribute name.

    Mike

  3. #3
    Join Date
    Aug 2006
    Posts
    65
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •