SitePoint Sponsor

User Tag List

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

    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;
    
        if (ticket.rNumber.selectedIndex == 0) { 
    		alert("Please select number of ticket!");
    		returnStatus = 0;
    	};
           
    	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
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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;
    	};
       //if( !(movieList.time[php echo $rows['name'];?>].checked)){
      	    //alert("Please choose screening time!");
      	    //returnStatus = 0;
    	 //};   
    	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:
    <input name="request" type="submit" id="request" value="Submit Request"  onclick="formSubmit(document.movieList)">


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
  •