SitePoint Sponsor

User Tag List

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

    pop up box not displaying

    Hi guys

    When a user doesnt select a radio button and presses the submit button a pop up box should display a message

    but it isnt?

    Can anyone see the error?

    PHP Code:
    <?php

    include 'header.php';
    ?>





    <script Language="JavaScript">
    <!--
    function board_checker()
    {
    // set var radio_choice to false
    var radio_choice = false;

    // Loop from zero to the one minus the number of radio button selections
    for (counter = 0;  counter < radio_form.board.length; counter++)
    {
    // If a radio button has been selected it will return true
    // (If not it will return false)
    if (radio_form.board[counter].checked)
    radio_choice = true; 
    }

    if (!radio_choice)
    {
    // If there were no selections made display an alert box 
    alert("Please select a letter.")
    return (false);
    }
    return (true);
    }

    -->
    </script>
       <font size="4">
    <B>Purchase</b></font>
    <br>
    <br>
    <table width="90%">
    <tr>
    <td>
    <font size="3" face="century gothic">

    <B>Products </B>  Options  Personal Details  Processor  Payment  <br>
    <font size="3">Step 1 of 5</font><br><bR></font>
    </td>
    <td align="right" valign="top">

    </td>
    </tr>
    </table>

    <form method="get" action="options.php" 
     onsubmit="return board_checker()" name="radio_form">
    <table width="100%"><tr><td width="60%">
    <font size="4"><B>Jobseeker and Employer Board 1.1 script </b><br>
    <font size="3">This package is for the job board owner looking to accept payments from employers to list there job vacancies.</font> </td>
    <td width="15%"><font size="3">999</font></td>     <td width="20%"><center>
    <input type="radio" value="jae" name="board"></center></td></tr>
    <tr>
    <td width="60%"><font size="4">
    <b>Company Board 1.1 script</b><br><font size="3">
    Companies who wish to to list there internal vaccancies.</td><td width="20%"><font size="3">99 Per Month</td><td width="15%"><center>
    <input type="radio" value="cb" name="board"></center></td>
    </tr>
    <tr>
    <td>
    </td>
    <td>
    </td>
    <td>
    <center><input type="submit" value="continue"></center>
    </td>
    </tr></table>
    </form>
    </body>
    </html>
    <?php

    include 'footer.php';
    ?>

  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)
    give your form an id of radio_form (same as the name) and replace your script with this.

    Code:
    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 letter.")
        
        return false;
    }


  3. #3
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you
    Last edited by wazo; Aug 21, 2007 at 14:33.

  4. #4
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would I do it if i have 4 radio boxes with different names on 1 page?

    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>


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
  •