SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    validation on different radio inputs

    Hi guys

    On this page I have 4 different radio inputs

    I need a pop up box everytime one of them isnt filled in

    How can I do this?

    PHP Code:
    <script Language="JavaScript">

    <!--

    function board_checker()

    {



        var radios = document.getElementById('radio_form').getElementsByTagName('INPUT');

        for(var i = 0; i < radios.length; i++) {

            if(radios[i].type == 'radio') {

                if(radios[i].checked)

                    return true;

            }

        }



        alert("Please select a script.")

        



        return false;





    }

    -->

    </script>

       <font size="4">

    <B>Options</b></font>

    <br>

    <br>

    <font size="3" face="century gothic">

      Products  <b>Options  </b> Personal Details  Processor  Payment<br></font>

    <font size="3">Step 2 of 5</font><br><bR></font>

      <table width="100%"><tr><td width="60%">





    <form  method="get" action="details.php" name="radio_form" onsubmit="return board_checker()">



     <input type="hidden" name="board" value="<? echo"$board"?>">



    <table>

    <tr>

    <td><font size="3" face="century gothic">

     <input type="radio" name="design" value="yes">yes

    </td>

    <td><font size="3" face="century gothic">

     <input type="radio" name="design" value="no">no

    </td>



    <td>

    <font size="3" face="century gothic">

    <b>Custom site design</b>

    <Br>

    Our team of designers can design your Job Script to your exact specification. We will also implemtent the design into the software. Designs normally 



    take 5 - 7 days.

    <Br>

    </td>

    <td width="200">

    <center><font size="3" face="century gothic"><b>750</b></center>

    </td>

    </tr>





    <tr>

    <td><font size="3" face="century gothic">

     <input type="radio" name="install" value="yes">yes

    </td><td><font size="3" face="century gothic">

     <input type="radio" name="install" value="no">no

    </td>

    <td><font size="3" face="century gothic">

    <b>Instalation</b>

    <br>

    Our team of programmers can take the hassle of installing your script by installing the software. All Installations are complete within 24 hours of 



    recieving server details.

    </td>

    <td width="200">

    <center><font size="3" face="century gothic"><b>50</b></center>

    </td>

    </tr>





    <tr>

    <td><font size="3" face="century gothic">

     <input type="radio" name="hosting" value="yes">yes

    </td><td><font size="3" face="century gothic">

     <input type="radio" name="hosting" value="no">no

    </td>

    <td><font size="3" face="century gothic">

    <B>Hosting</b>

    <br>

    We provide hosting for all of our software. Your hosting account will be live instantly after checkout.

    </td>

    <td width="200"><center>

    <font size="3" face="century gothic"><B>19.99 / Month</b> </center>

    </td>

    </tr>









    <tr>

    <td><font size="3" face="century gothic">

     <input type="radio" name="mod" value="yes">yes

    </td><td><font size="3" face="century gothic">

     <input type="radio" name="mod" value="no">no

    </td>

    <td><font size="3" face="century gothic">

    <B>Modifications</b>

    <br>

    Our programmers can add modifications to the software if needed. We will contact you via yuor preffered method to discuss what modifications you 



    want.

    </td>

    <td>

    <center>

    <font size="3" face="century gothic"><B>Quote</b> </center>

    </td>

    </tr>

    </table>

    <Br>

    <input type="submit" value="Continue">

    </form>

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry I didn't reply to your previous thread, i'm a little busy at the moment

    Could you provide a sample of the page you want it to go on?


  3. #3
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I posted the script in my previous post above

  4. #4
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hth

    i've given your table rows containing each group of radio buttons an id, and then told the script to check the values within those table rows.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title>Untitled Document</title>
            <link rel="stylesheet" type="text/css" media="screen" />
            <style type="text/css"></style>
            <script type="text/javascript"></script>
        </head>
        <body>
                
    <script Language="JavaScript">
    <!--
    function test() {
        var returnValue = true;
        if(!board_checker('design')) {
            alert('no design value selected');
            returnValue = false;
        }
        if(!board_checker('install')) {
            alert('no install value selected');
            returnValue = false;
        }
        if(!board_checker('hosting')) {
            alert('no hosting value selected');
            returnValue = false;
        }
        if(!board_checker('mod')) {
            alert('no mod value selected');
            returnValue = false;
        }
        return returnValue;
    }
    function board_checker(parent)
    {
        var radios = document.getElementById(parent).getElementsByTagName('INPUT');
        for(var i = 0; i < radios.length; i++) {
            if(radios[i].type == 'radio') {
                if(radios[i].checked)
                    return true;
            }
        }   
    
        return false;
    }
    -->
    </script>
       <font size="4">
    <B>Options</b></font>
    <br>
    <br>
    <font size="3" face="century gothic">
      Products &#187; <b>Options &#187; </b> Personal Details &#187; Processor &#187; Payment<br></font>
    <font size="3">Step 2 of 5</font><br><bR></font>
      <table width="100&#37;"><tr><td width="60%"><form method="get" action="details.php" name="radio_form" onsubmit="return test();">
    
     <input type="hidden" name="board" value="<? echo $board; ?>">
    
    <table>
    <tr id="design">
    <td><font size="3" face="century gothic">
     <input type="radio" name="design" value="yes">yes
    </td>
    <td><font size="3" face="century gothic">
     <input type="radio" name="design" value="no">no
    </td>
    
    <td>
    <font size="3" face="century gothic">
    <b>Custom site design</b>
    <Br>
    Our team of designers can design your Job Script to your exact specification. We will also implemtent the design into the software. Designs normally 
    
    take 5 - 7 days.
    <Br>
    </td>
    <td width="200">
    <center><font size="3" face="century gothic"><b>&#163;750</b></center>
    </td>
    </tr><tr id="install">
    <td><font size="3" face="century gothic">
     <input type="radio" name="install" value="yes">yes
    </td><td><font size="3" face="century gothic">
     <input type="radio" name="install" value="no">no
    </td>
    <td><font size="3" face="century gothic">
    <b>Instalation</b>
    <br>
    Our team of programmers can take the hassle of installing your script by installing the software. All Installations are complete within 24 hours of 
    
    recieving server details.
    </td>
    <td width="200">
    <center><font size="3" face="century gothic"><b>&#163;50</b></center>
    </td>
    </tr><tr id="hosting">
    <td><font size="3" face="century gothic">
     <input type="radio" name="hosting" value="yes">yes
    </td><td><font size="3" face="century gothic">
     <input type="radio" name="hosting" value="no">no
    </td>
    <td><font size="3" face="century gothic">
    <B>Hosting</b>
    <br>
    We provide hosting for all of our software. Your hosting account will be live instantly after checkout.
    </td>
    <td width="200"><center>
    <font size="3" face="century gothic"><B>&#163;19.99 / Month</b> </center>
    </td>
    </tr>
    
    <tr id="mod">
    <td><font size="3" face="century gothic">
     <input type="radio" name="mod" value="yes">yes
    </td><td><font size="3" face="century gothic">
     <input type="radio" name="mod" value="no">no
    </td>
    <td><font size="3" face="century gothic">
    <B>Modifications</b>
    <br>
    Our programmers can add modifications to the software if needed. We will contact you via yuor preffered method to discuss what modifications you 
    
    want.
    </td>
    <td>
    <center>
    <font size="3" face="century gothic"><B>Quote</b> </center>
    </td>
    </tr>
    </table>
    <Br>
    <input type="submit" value="Continue">
    </form>
    
        </body>
    </html>


  5. #5
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks


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
  •