Results 1 to 3 of 3

Thread: Drop down menu failed to validate

  1. #1
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Drop down menu failed to validate

    Hi..guys.I have a static display drop down menu,however it doesn't go through the validation function when option is not selected.Thanks for your generious help...

    Code:
    <script language="JavaScript" type="text/JavaScript">
    function formSubmit(ticket)
    {
    	var returnStatus = 1;
    
    		returnStatus = 0;
        if (ticket.rNumber.selectedIndex == 0) { 
    		alert("Please select number of ticket!");
    	};
           
    	if (returnStatus) { 
    		window.location='home.php'
    	}
    }
    </script>
    Code:
     <select name="rNumber" id="select4">
                          <option selected>Select</option>
                          <option>01</option>
                          <option>02</option>
                          <option>03</option>
                          <option>04</option>
                          <option>05</option>
                          <option>06</option>
    </select>
    Code:
    <form action="" method="post" 
    name="movieList" id="movieList">
    .......
    .......
    .......
    <input name="request" type="submit" id="request" value="Submit Request"    onclick="formSubmit(document.movieList)">

  2. #2
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    use <script type="text/javascript"> instead of your javascript tag.
    Trinithis

  3. #3
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for reply,problem resolved.Actually the <form>tag was placed wrongly.However,when mixed with another dynamic radio button written in PHP,the validation of radio button become failed.

    Code:
    <script language="JavaScript" type="text/JavaScript">
    function formSubmit(ticket)
    {
    	var returnStatus = 1;
    
        if (ticket.rNumber.selectedIndex == 0){ 
    		alert("Please select number of ticket!");
    		returnStatus = 0;
    	};
       else if( !(movieList.time[<?php echo $rows['name']; ?>].checked)){
      	    alert("Please choose screening time!");
      	    returnStatus = 0;
    	 };   
    	else if (returnStatus) { 
    		window.location='home.php';
    	};
    }
    </script>
    PHP Code:

    <?
    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']; ?>]"
                  value="<?php echo $time?>">
                <?php echo $time?>&nbsp;&nbsp;&nbsp;
                </label>
                <?php ?>
    <?
        
    }


    }
    ?>
    Code:
    <form action="" method="post" name="movieList" id="movieList">
    .......
    .......          
    <input name="request" type="submit" id="request" value="Submit Request"          onclick="formSubmit(document.movieList)">
    Last edited by devil_vin; 09-23-2007 at 05:10 PM.

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
  •