Jump to content

PravinS

Members
  • Posts

    459
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by PravinS

  1. Check this simple logic

     

    <table border="0" cellspacing="0" cellpadding="5">
    <tr>
    <?php
        $array = array(1,2,3,4,5,6);
        $i = 1;
        foreach($array as $val)
        {
            echo '<td>'.$val.'</td>';
            if ($i % 2 == 0)
                 echo "</td></tr>";
          $i++;
        }
    ?>
    </tr>
    </table>
    

    I hope this will help you

  2. use this updated javascript function

    function checkForm()
    {
    	var obj = document.getElementsByName('dest[]');
    	var destCount = obj.length;
    	var destSel   = false;
    	for(var i = 0; i < destCount; i++)
    	{
    		if(obj[i].checked == true)
    			destSel = true;
    	}
    	if(destSel == false)
    	{
    		alert('Select one or more destinations');
    	}
    	return destSel;
    }
    
  3. use this code

    
    <html>
    <head>
    <script language="javascript">
    function checkForm(){
    var obj = document.getElementsByName('dest[]');
    var destCount = obj.length;
    var destSel   = false;
    for(i = 0; i < destCount; i++){
    if(obj.checked == false){
    destSel = true;
    break;
    }
    }
    
    if(!destSel){
    alert('Select one or more destinations');
    }
    return destSel;
    }
    </script>
    </head>
    <body>
    Select at least one destination
    <form action="" method="post">
    <input id="cx" type="checkbox" name="dest[]" value="CX" />   <label for="cx">Cox's Bazar</label><br />
    <input id="su" type="checkbox" name="dest[]" value="SU" />   <label for="su">Sundarban</label><br />
    <input id="sy" type="checkbox" name="dest[]" value="SY" />   <label for="sy">Sylhet</label><br />
    <input id="ch" type="checkbox" name="dest[]" value="CH" />   <label for="ch">Chittagong</label><br />
    <br />
    <input type="submit" name="Go" value="  Go  "  onclick="return checkForm();"/>
    </form>
    </body>
    </html>
    
    

    also check the jsfiddle

  4. Just remove  onsubmit="return checkForm(this);" from form tag and add it to button as  onclick="return checkForm(this);"

     

    Use this

    <form action="" method="post">
    <input id="cx" type="checkbox" name="dest[]" value="CX" />   <label for="cx">Cox's Bazar</label><br />
    <input id="su" type="checkbox" name="dest[]" value="SU" />   <label for="su">Sundarban</label><br />
    <input id="sy" type="checkbox" name="dest[]" value="SY" />   <label for="sy">Sylhet</label><br />
    <input id="ch" type="checkbox" name="dest[]" value="CH" />   <label for="ch">Chittagong</label><br />
    <br />
    <input type="submit" name="Go" value="  Go  "  onclick="return checkForm(this);"/>
    </form>
    
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.