|
|
|
อยากแก้ถ้าไม่เลือก Dropdown ทั้งสามอัน ให้ขึ้นข้อความและส่งค่าไม่ได้ทำอย่างไรครับผม |
|
|
|
|
|
|
|
ใช้ jQuery ควบคุมครับ
|
|
|
|
|
Date :
2013-08-01 15:14:12 |
By :
popnakub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<!doctype>
<html>
<head>
<title>:: Check Dropdown list ::</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
</head>
<body>
<form name="myapps" action="#" method="POST">
<select name="ddl[]" class="ddl">
<option value="0"></option>
<option value="1">COM1</option>
<option value="2">COM2</option>
</select><br>
<select name="ddl[]" class="ddl">
<option value="0"></option>
<option value="1">COM1</option>
<option value="2">COM2</option>
</select><br>
<select name="ddl[]" class="ddl">
<option value="0"></option>
<option value="1">COM1</option>
<option value="2">COM2</option>
</select><br>
<input type="submit" name="btn_submit" value="Click">
</form>
<hr>
<?php
echo "<pre>", print_r($_POST), "</pre>";
?>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
$("form").submit(function(e){
var ddl = $(".ddl").val();
if(ddl == 0){
alert("Error ! ");
e.preventDefault();
}
});
});
</script>
|
|
|
|
|
Date :
2013-08-01 15:29:07 |
By :
popnakub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|