SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: radio buttons

  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    radio buttons

    At the moment its too late to think and i cannot work out how to make sure a radio button is ticked before submitting the form.

    Heres what i have so far

    PHP Code:

    <script>

    function 
    validate()
    {
        
    document.Contact;

        if (
    x.Site.value=='' || x.URL.value=='' || x.RequestType.value=='a1')
        {
            
        }
        else
        {    
            
    Contact.action 'http://www.9cy.com/hosted2/user_formmail.cgi';
            
    Contact.submit();
            
    x.send.disabled=true;
            
    setTimeout('x.send.disabled = false',1000);
        }
    }

    </script> 

    Code:
    <table width="80%" border="0" cellspacing="0" cellpadding="0">
                        <tr> 
                          <td width="50%">Site Name</td>
                          <td width="50%"> 
                            <input type="text" name="Site" size="45">
                          </td>
                        </tr>
                        <tr> 
                          <td width="50%">Address (URL)</td>
                          <td width="50%"> 
                            <input type="text" name="URL" size="45">
                          </td>
                        </tr>
                        <tr> 
                          <td width="50%">Type of Request</td>
                          <td width="50%"> 
                            <input type="radio" name="RequestType" value="a1" onclick='this.value=1'>
                            New Link 
                            <input type="radio" name="RequestType" value="a1" onclick='this.value=1'>
                            Report Invalid Link</td>
                        </tr>
                        <tr> 
                          <td width="50%">&nbsp;</td>
                          <td width="50%"> <br>
                            <input type="button" name="send" value="Request" onClick="validate()">
                          </td>
                        </tr>
                      </table>

  2. #2
    SitePoint Addict Caterwomtious's Avatar
    Join Date
    Dec 2001
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if (document.forms['yourFormName'].elements['yourCheckBoxName'].checked) //whatever you want...

  3. #3
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    if(x.RequestType[0].value == "a1" && x.RequestType[1].value == "a1") {
      alert("Please select a type of request.");
    }
    OR

    Code:
    if(!x.RequestType[0].checked && !x.RequestType[1].checked) {
      alert("Please select a type of request.");
    }
    I think both of these (or some variation of) will work.
    Last edited by makeda; Apr 7, 2002 at 19:37.


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
  •