SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unstoppable Form Validation

    Hi..guys! I have a function here to validate null selection of drop down menu and radio button.However,it seems like alert box couldn't be stopped display even though both fileds were already selected.Thanks for your generious help

    Code:
    <script language="JavaScript" type="text/JavaScript">
    function nullValidation() {
        var x=document.getElementById("movieList");
        for (var i=0;i<x.length;i++)
        {
          if(x.elements[i].checked=="" || x.elements[i].selectedIndex == 0) 
          {
            alert("Please select "+x.elements[i].title+".");
            x.elements[i].focus();
            return false;
          }
        
        }
    return true;
    }
    </script>
    Code:
    <form action="" method="post" name="movieList" 
    onSubmit="return nullValidation();">

  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)
    use the childNodes collection x.childNodes.length instead of x.length.

    Also, you should check if the element is an element that can be interacted with ie

    input, select, textarea etc

    also, not sure what x.elements[i].title is meant to produce.

    Can you provide teh form your wanting to validate, and maybe we can help.


  3. #3
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My form only consists of 2 elements,drop down menu and radio button.The one which couldn't be stopped is radio button.

    Code:
    <select name="rNumber" title="number of ticket">
                          <option selected>Select</option>
                          <option>01</option>
                          <option>02</option>
                          <option>03</option>
                          <option>04</option>
                          <option>05</option>
                          <option>06</option>
    </select>
    Code:
    <input type="radio"  name="time[<?php echo $rows['name']; ?>]"
    title ="screening time" value="<?php echo $time; ?>">
    <?php echo $time; ?>&nbsp;&nbsp;&nbsp;
    </label>

  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)
    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">
                function validate(which) {
                    var selects = which.getElementsByTagName('SELECT');
                    var radios = which.getElementsByTagName('INPUT');
                    for(sel = 0; sel < selects.length; sel++) {
                        if(selects[sel].options[selects[sel].selectedIndex].text == 'Select') {
                            alert('error [select]');
                            return false;
                        }
                    }
                    var rselCount = 0;
                    for(radio = 0; radio < radios.length; radio++) {
                        if(radio.checked)
                            rselCount++;
                    }
                    if(rselCount == 0) {
                        alert('error [radio]');
                        return false;
                    }
                    return true;
                }
            </script>
        </head>
        <body>
            
            <form onsubmit="return validate(this);">
                <select name="rNumber" title="number of ticket">
                          <option selected>Select</option>
                          <option>01</option>
                          <option>02</option>
                          <option>03</option>
                          <option>04</option>
                          <option>05</option>
                          <option>06</option>
                </select>
                <br />
                <br />
                <input type="radio" name="test[]" /> 1
                <br />
                <input type="radio" name="test[]" /> 2
                <br />
                <input type="radio" name="test[]" /> 3
                <br />
                <br />
                <input type="submit" value="Go" />
            </form>
    
        </body>
    </html>


  5. #5
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The function can't work at all.What went wrong?

  6. #6
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean it can't work? I've tested it in both Firefox and IE and they both work fine. Could you post your code along with how you have used my example?


  7. #7
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am mixing Javascript with PHP,no alert box displayed this time.

    PHP Code:
    <?php
    include ('dbconn.cfg'); // database configuration file
    $connection = @mysql_connect("localhost""root""") or die("Cannot connect to server!");

     
    session_start();
     
    //echo 'Your selected date is = ' . $_GET['selected_date'];
     //$_SESSION['my_date'] = $_POST['rDate'];
    //session_unset($_SESSION['n']);
    ?>


    <!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>Blue Projection - Reservation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    table, table * {
         margin: 0;
         padding: 0;
         text-align: left;
    }
    </style>
    <script language="JavaScript" type="text/JavaScript">
    function validate(which) {
             var selects = which.getElementsByTagName('select');
             var radios = which.getElementsByTagName('input');
             for(sel = 0; sel < selects.length; sel++) {
                if(selects[sel].options[selects[sel].selectedIndex].text == 'Select') {
                    alert('error [select]');
                    return false;
                }
             }
             
              var rselCount = 0;
              for(radio = 0; radio < radios.length; radio++) {
                  if(radio.checked)
                      rselCount++;
                  }
                  if(rselCount == 0) {
                       alert('error [radio]');
                       return false;
                    }
                    return true;
                }
                    
                    
     }
                    
    </script>

    </head>

    <body>
    <table width="80%" height="557" border="0" align="center" bgcolor="#CCCCFF">
      <tr> 
        <td colspan="2"> <div align="center"> 
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="800" height="300">
              <param name="movie" value="flash%20menu/menu2.swf">
              <param name="quality" value="high">
              <param name="LOOP" value="false">
              <embed src="flash%20menu/menu2.swf" width="800" height="300" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>
          </div></td>
      </tr>
      <tr> 
        <td width="3%">&nbsp;</td>
        <td width="97%" height="222"> 
          <table width="100%" border="0">
            <tr> 
              <td width="78%" height="29"><font color="#0000FF" size="+2" face="Arial">Online 
                Reservation</font></td>
                <?
    if (isset($_SESSION['gmemberid'])) {
    ?>
     <td><b><font color="blue">Logged in as: <? echo $_SESSION['gmemberid']; ?></font></b></td><br><br>
    <? ?>
             
            </tr>
            <tr> 
              <td height="21" colspan="2"><div align="left"><font face="Arial"><img src="images/line2.JPG" width="750" height="4"></font></div></td>
            </tr>

             <form action="" method="post" name="movieList" 
              onSubmit="return validate(this);">
              
                     <tr> 
                       <label>You selected <?= $_GET['selected_date']; ?>!</label>
                      <td><font face="Arial"> 
                        <label>Number of Tickets:</label>
                        </font>
                         <font face="Arial"> 
                        <select name="rNumber" title="number of ticket">
                          <option selected>Select</option>
                          <option>01</option>
                          <option>02</option>
                          <option>03</option>
                          <option>04</option>
                          <option>05</option>
                          <option>06</option>
                        </select>
                        <label><b>**Ticket price RM 9/ticket**</b></label>
                        </font></td>
                    </tr>
            <tr> 
              <td height="40" colspan="2"> <p><font face="Arial">Choose a movie and 
                  its showtime<br>
                  </font></p></td>
            </tr>
            
                
                
                
    <?
    if (isset($_SESSION['gmemberid'])) {

        
    $tbl_name "movie";
        
    $result mysql_query(sprintf('SELECT name,classification,screeningTime FROM %s
                 LIMIT 7'
    $tbl_name)) or die('Cannot execute query.');


        
    //$numrow = mysql_num_rows($result);


        
    while ($rows mysql_fetch_assoc($result)) {
            echo 
    '<table width="100%" border="0"><tr><td height="68">
                      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br>'
    ;

            echo 
    '<strong>' $rows['name'] . ' (' $rows['classification'] . ')
                     <br></strong>'
    ;
            foreach (
    explode(','$rows['screeningTime']) as $time) { ?>
                <label>
                <input type="radio"  name="time[<?php echo $rows['name']; ?>]"
                  title ="screening time" value="<?php echo $time?>">
                <?php echo $time?>&nbsp;&nbsp;&nbsp;
                </label>
                <?php ?>
    <?
        
    }

    }
    ?>    
         
            <tr> 
      <td><input name="request" type="submit" value="Submit Request">
                        &nbsp;
                        <input name="back" type="button" value="Back"
                         onclick="window.location='reservation.php'"> </td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                    </tr>
                  </table>
                </form></td>
            </tr>
            <tr> 
              <td height="6" colspan="2"><font face="Arial"><img src="images/line2.JPG" width="750" height="4"></font></td>
            </tr>
          </table></td>
      </tr>
      <tr> 
        <td width="3%" height="25">&nbsp;</td>
        <td>&nbsp; </td>
      </tr>
    </table>
    </body>
    </html>

  8. #8
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, another request. Could you grab the parse source code from your browser? ie run this script and copy and paste the view source result. That way all the fields you want to check will be present etc.


  9. #9
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry,what do you mean by parse source code? Is it plain HTML code?Thanks

    reservation2.php
    HTML 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>Blue Projection - Reservation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    table, table * {
         margin: 0;
         padding: 0;
         text-align: left;
    }
    </style>
    <script language="JavaScript" type="text/JavaScript">
    function validate(which) {
             var selects = which.getElementsByTagName('select');
             var radios = which.getElementsByTagName('input');
             for(sel = 0; sel < selects.length; sel++) {
                if(selects[sel].options[selects[sel].selectedIndex].text == 'Select') {
                    alert('error [select]');
                    return false;
                }
             }
             
              var rselCount = 0;
              for(radio = 0; radio < radios.length; radio++) {
                  if(radio.checked)
                      rselCount++;
                  }
                  if(rselCount == 0) {
                       alert('error [radio]');
                       return false;
                    }
                    return true;
                }
                    
                    
     }
                    
    </script>
    
    </head>
    
    <body>
    <table width="80&#37;" height="557" border="0" align="center" bgcolor="#CCCCFF">
      <tr> 
        <td colspan="2"> <div align="center"> 
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="800" height="300">
              <param name="movie" value="flash%20menu/menu2.swf">
              <param name="quality" value="high">
              <param name="LOOP" value="false">
              <embed src="flash%20menu/menu2.swf" width="800" height="300" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>
          </div></td>
      </tr>
      <tr> 
        <td width="3%">&nbsp;</td>
        <td width="97%" height="222"> 
          <table width="100%" border="0">
            <tr> 
              <td width="78%" height="29"><font color="#0000FF" size="+2" face="Arial">Online 
                Reservation</font></td>
                 <td><b><font color="blue">Logged in as: siongck@gmail.com</font></b></td><br><br>
             
            </tr>
            <tr> 
              <td height="21" colspan="2"><div align="left"><font face="Arial"><img src="images/line2.JPG" width="750" height="4"></font></div></td>
            </tr>
    
             <form action="" method="post" name="movieList" 
    		  onSubmit="return validate(this);">
              
                     <tr> 
                       <label>You selected Wed 26th Sep!</label>
                      <td><font face="Arial"> 
                        <label>Number of Tickets:</label>
                        </font>
                         <font face="Arial"> 
                        <select name="rNumber" title="number of ticket">
                          <option selected>Select</option>
                          <option>01</option>
                          <option>02</option>
                          <option>03</option>
                          <option>04</option>
                          <option>05</option>
                          <option>06</option>
                        </select>
                        <label><b>**Ticket price RM 9/ticket**</b></label>
                        </font></td>
                    </tr>
            <tr> 
              <td height="40" colspan="2"> <p><font face="Arial">Choose a movie and 
                  its showtime<br>
                  </font></p></td>
            </tr>
            
    	    	
                
                
    <table width="100%" border="0"><tr><td height="68">
    			      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Rogue Assassin (U)
    			     <br></strong>			<label>
                <input type="radio"  name="time[Rogue Assassin]"
    			  title ="screening time" value="12:00pm">
                12:00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rogue Assassin]"
    			  title ="screening time" value="2:00pm">
                2:00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rogue Assassin]"
    			  title ="screening time" value="4:00pm">
                4:00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rogue Assassin]"
    			  title ="screening time" value="6:00pm">
                6:00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rogue Assassin]"
    			  title ="screening time" value="8:00pm">
                8:00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rogue Assassin]"
    			  title ="screening time" value="10:00pm">
                10:00pm&nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
    			      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Black Sheep (U)
    			     <br></strong>			<label>
                <input type="radio"  name="time[Black Sheep]"
    			  title ="screening time" value="1:00pm">
                1:00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Black Sheep]"
    			  title ="screening time" value="2 :00pm">
                2 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Black Sheep]"
    			  title ="screening time" value="5 :00pm">
                5 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Black Sheep]"
    			  title ="screening time" value=" 7:00pm">
                 7:00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Black Sheep]"
    			  title ="screening time" value="9:00pm">
                9:00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Black Sheep]"
    			  title ="screening time" value="11:00pm">
                11:00pm&nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
    			      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Fracture (U)
    			     <br></strong>			<label>
                <input type="radio"  name="time[Fracture]"
    			  title ="screening time" value="1:00pm	">
                1:00pm	&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Fracture]"
    			  title ="screening time" value="3 :00pm">
                3 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Fracture]"
    			  title ="screening time" value="6 :00pm">
                6 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
    			      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>White Noise 2: The Light (18PL)
    			     <br></strong>			<label>
                <input type="radio"  name="time[White Noise 2: The Light]"
    			  title ="screening time" value="1:00pm	">
                1:00pm	&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[White Noise 2: The Light]"
    			  title ="screening time" value="2 :00pm">
                2 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[White Noise 2: The Light]"
    			  title ="screening time" value="5 :00pm">
                5 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[White Noise 2: The Light]"
    			  title ="screening time" value="7 :30pm">
                7 :30pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[White Noise 2: The Light]"
    			  title ="screening time" value="9 :45pm	 ">
                9 :45pm	 &nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
    			      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Rogue Assassin  (18PL)
    			     <br></strong>			<label>
                <input type="radio"  name="time[Rogue Assassin ]"
    			  title ="screening time" value="1:00pm	">
                1:00pm	&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rogue Assassin ]"
    			  title ="screening time" value="2 :30pm">
                2 :30pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rogue Assassin ]"
    			  title ="screening time" value="5 :45pm">
                5 :45pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rogue Assassin ]"
    			  title ="screening time" value="6 :00pm">
                6 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rogue Assassin ]"
    			  title ="screening time" value="9 :20pm">
                9 :20pm&nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
    			      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Rush Hour 3  (U)
    			     <br></strong>			<label>
                <input type="radio"  name="time[Rush Hour 3 ]"
    			  title ="screening time" value="1:00pm	">
                1:00pm	&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rush Hour 3 ]"
    			  title ="screening time" value="2 :00pm">
                2 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rush Hour 3 ]"
    			  title ="screening time" value="5 :00pm">
                5 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rush Hour 3 ]"
    			  title ="screening time" value="7 :00pm">
                7 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rush Hour 3 ]"
    			  title ="screening time" value="9 :00pm">
                9 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Rush Hour 3 ]"
    			  title ="screening time" value="11:00pm">
                11:00pm&nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
    			      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Train Of The Dead  (18PL)
    			     <br></strong>			<label>
                <input type="radio"  name="time[Train Of The Dead ]"
    			  title ="screening time" value="1:30pm	">
                1:30pm	&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Train Of The Dead ]"
    			  title ="screening time" value="2 :30pm">
                2 :30pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Train Of The Dead ]"
    			  title ="screening time" value="6 :00pm">
                6 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Train Of The Dead ]"
    			  title ="screening time" value="8 :00pm">
                8 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                			<label>
                <input type="radio"  name="time[Train Of The Dead ]"
    			  title ="screening time" value="9 :30pm">
                9 :30pm&nbsp;&nbsp;&nbsp;
                </label>
                	
         
            <tr> 
      <td><input name="request" type="submit" value="Submit Request">
                        &nbsp;
                        <input name="back" type="button" value="Back"
    					 onclick="window.location='reservation.php'"> </td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                    </tr>
                  </table>
                </form></td>
            </tr>
            <tr> 
              <td height="6" colspan="2"><font face="Arial"><img src="images/line2.JPG" width="750" height="4"></font></td>
            </tr>
          </table></td>
      </tr>
      <tr> 
        <td width="3%" height="25">&nbsp;</td>
        <td>&nbsp; </td>
      </tr>
    </table>
    </body>
    </html>

  10. #10
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script language="JavaScript" type="text/JavaScript">
        function validate(which) {
            var selects = which.getElementsByTagName('select');
            var radios = which.getElementsByTagName('input');
            for(sel = 0; sel < selects.length; sel++) {
                if(selects[sel].options[selects[sel].selectedIndex].text == 'Select') {
                    alert('error [select]');
                    return false;
                }
            }
    
            var rselCount = 0;
            for(radio = 0; radio < radios.length; radio++) {
                if(radio.checked) {
                  rselCount++;
                }
            }
    
            if(rselCount == 0) {
               alert('error [radio]');
               return false;
            }
            return true;
        }
                    
    </script>

    Working now...


  11. #11
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ya.working now,however didn't solve my original problem as both fields were selected,why alert('error [radio]'); still display??

  12. #12
    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 missed something:

    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>Blue Projection - Reservation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    table, table * {
         margin: 0;
         padding: 0;
         text-align: left;
    }
    </style>
    <script language="JavaScript" type="text/JavaScript">
        function validate(which) {
            var selects = which.getElementsByTagName('select');
            var radios = which.getElementsByTagName('input');
            for(sel = 0; sel < selects.length; sel++) {
                if(selects[sel].options[selects[sel].selectedIndex].text == 'Select') {
                    alert('error [select]');
                    return false;
                }
            }
    
            var rselCount = 0;
            for(radio = 0; radio < radios.length; radio++) {
                if(radios[radio].checked) {
                  rselCount++;
                }
            }
    
            if(rselCount == 0) {
               alert('error [radio]');
               return false;
            }
            return true;
        }
                    
    </script>
    
    </head>
    
    <body>
    
             <form action="" method="post" name="movieList" 
              onSubmit="return validate(this);">
    <table width="80&#37;" height="557" border="0" align="center" bgcolor="#CCCCFF">
      <tr> 
        <td colspan="2"> <div align="center"> 
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="800" height="300">
              <param name="movie" value="flash%20menu/menu2.swf">
              <param name="quality" value="high">
              <param name="LOOP" value="false">
              <embed src="flash%20menu/menu2.swf" width="800" height="300" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>
          </div></td>
      </tr>
      <tr> 
        <td width="3%">&nbsp;</td>
        <td width="97%" height="222"> 
          <table width="100%" border="0">
            <tr> 
              <td width="78%" height="29"><font color="#0000FF" size="+2" face="Arial">Online 
                Reservation</font></td>
                 <td><b><font color="blue">Logged in as: siongck@gmail.com</font></b></td><br><br>
             
            </tr>
            <tr> 
              <td height="21" colspan="2"><div align="left"><font face="Arial"><img src="images/line2.JPG" width="750" height="4"></font></div></td>
            </tr>
              
                     <tr> 
                       <label>You selected Wed 26th Sep!</label>
                      <td><font face="Arial"> 
                        <label>Number of Tickets:</label>
                        </font>
                         <font face="Arial"> 
                        <select name="rNumber" title="number of ticket">
                          <option selected>Select</option>
                          <option>01</option>
                          <option>02</option>
                          <option>03</option>
                          <option>04</option>
                          <option>05</option>
                          <option>06</option>
                        </select>
                        <label><b>**Ticket price RM 9/ticket**</b></label>
                        </font></td>
                    </tr>
            <tr> 
              <td height="40" colspan="2"> <p><font face="Arial">Choose a movie and 
                  its showtime<br>
                  </font></p></td>
            </tr>
            
                
                
                
    <table width="100%" border="0"><tr><td height="68">
                      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Rogue Assassin (U)
                     <br></strong>            <label>
                <input type="radio"  name="time[Rogue Assassin]"
                  title ="screening time" value="12:00pm">
                12:00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rogue Assassin]"
                  title ="screening time" value="2:00pm">
                2:00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rogue Assassin]"
                  title ="screening time" value="4:00pm">
                4:00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rogue Assassin]"
                  title ="screening time" value="6:00pm">
                6:00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rogue Assassin]"
                  title ="screening time" value="8:00pm">
                8:00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rogue Assassin]"
                  title ="screening time" value="10:00pm">
                10:00pm&nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
                      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Black Sheep (U)
                     <br></strong>            <label>
                <input type="radio"  name="time[Black Sheep]"
                  title ="screening time" value="1:00pm">
                1:00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Black Sheep]"
                  title ="screening time" value="2 :00pm">
                2 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Black Sheep]"
                  title ="screening time" value="5 :00pm">
                5 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Black Sheep]"
                  title ="screening time" value=" 7:00pm">
                 7:00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Black Sheep]"
                  title ="screening time" value="9:00pm">
                9:00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Black Sheep]"
                  title ="screening time" value="11:00pm">
                11:00pm&nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
                      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Fracture (U)
                     <br></strong>            <label>
                <input type="radio"  name="time[Fracture]"
                  title ="screening time" value="1:00pm    ">
                1:00pm    &nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Fracture]"
                  title ="screening time" value="3 :00pm">
                3 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Fracture]"
                  title ="screening time" value="6 :00pm">
                6 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
                      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>White Noise 2: The Light (18PL)
                     <br></strong>            <label>
                <input type="radio"  name="time[White Noise 2: The Light]"
                  title ="screening time" value="1:00pm    ">
                1:00pm    &nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[White Noise 2: The Light]"
                  title ="screening time" value="2 :00pm">
                2 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[White Noise 2: The Light]"
                  title ="screening time" value="5 :00pm">
                5 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[White Noise 2: The Light]"
                  title ="screening time" value="7 :30pm">
                7 :30pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[White Noise 2: The Light]"
                  title ="screening time" value="9 :45pm     ">
                9 :45pm     &nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
                      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Rogue Assassin  (18PL)
                     <br></strong>            <label>
                <input type="radio"  name="time[Rogue Assassin ]"
                  title ="screening time" value="1:00pm    ">
                1:00pm    &nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rogue Assassin ]"
                  title ="screening time" value="2 :30pm">
                2 :30pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rogue Assassin ]"
                  title ="screening time" value="5 :45pm">
                5 :45pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rogue Assassin ]"
                  title ="screening time" value="6 :00pm">
                6 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rogue Assassin ]"
                  title ="screening time" value="9 :20pm">
                9 :20pm&nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
                      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Rush Hour 3  (U)
                     <br></strong>            <label>
                <input type="radio"  name="time[Rush Hour 3 ]"
                  title ="screening time" value="1:00pm    ">
                1:00pm    &nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rush Hour 3 ]"
                  title ="screening time" value="2 :00pm">
                2 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rush Hour 3 ]"
                  title ="screening time" value="5 :00pm">
                5 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rush Hour 3 ]"
                  title ="screening time" value="7 :00pm">
                7 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rush Hour 3 ]"
                  title ="screening time" value="9 :00pm">
                9 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Rush Hour 3 ]"
                  title ="screening time" value="11:00pm">
                11:00pm&nbsp;&nbsp;&nbsp;
                </label>
                <table width="100%" border="0"><tr><td height="68">
                      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br><strong>Train Of The Dead  (18PL)
                     <br></strong>            <label>
                <input type="radio"  name="time[Train Of The Dead ]"
                  title ="screening time" value="1:30pm    ">
                1:30pm    &nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Train Of The Dead ]"
                  title ="screening time" value="2 :30pm">
                2 :30pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Train Of The Dead ]"
                  title ="screening time" value="6 :00pm">
                6 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Train Of The Dead ]"
                  title ="screening time" value="8 :00pm">
                8 :00pm&nbsp;&nbsp;&nbsp;
                </label>
                            <label>
                <input type="radio"  name="time[Train Of The Dead ]"
                  title ="screening time" value="9 :30pm">
                9 :30pm&nbsp;&nbsp;&nbsp;
                </label>
                    
         
            <tr> 
      <td><input name="request" type="submit" value="Submit Request">
                        &nbsp;
                        <input name="back" type="button" value="Back"
                         onclick="window.location='reservation.php'"> </td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                    </tr>
                  </table>
               </td>
            </tr>
            <tr> 
              <td height="6" colspan="2"><font face="Arial"><img src="images/line2.JPG" width="750" height="4"></font></td>
            </tr>
          </table></td>
      </tr>
      <tr> 
        <td width="3%" height="25">&nbsp;</td>
        <td>&nbsp; </td>
      </tr>
    </table>
     </form>
    </body>
    </html>
    I've also moved the form to outside the table.


  13. #13
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem resolved.Thanks for your initiative help.


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
  •