私は借りボタンの検証を作成しようとしていますが、押されてもチェックされていないアイテムはないので、プロンプトを表示するはずですが、プロンプトが表示されず、明らかにデータベースに保存されません。どうすればこれをやろうとしますか?チェックボックスがチェックされているかどうかを確認する方法
以下はjavascriptのコードです。
$(".uniform_on").change(function(){
var max = 1;
if ($(".uniform_on:checked").length < max) {
$(".uniform_on").attr('disabled', 'disabled');
alert('Please Check the item of equipment to be borrowed!');
$(".uniform_on:checked").removeAttr('disabled');
} else {
$(".uniform_on").removeAttr('disabled');
}
})
を(これも右である場合、私は知らない)私は自分でコードをカスタマイズするので、私は、コードのほとんど知りません助け、私はもののこの種の限られた知識を持ってしてください。チェックボックスをチェックせずに借用ボタンを押すとどうなりますか?これを検証して、ユーザーが何かを最初にチェックしてから、再度借りることを確認します。ありがとう。
これは私の借用のために全体のコード
<?php include('header.php'); ?>
<?php include('session.php'); ?>
<?php include('navbar_borrow.php'); ?>
<div class="container">
<div class="margin-top">
<div class="row">
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong><i class="icon-user icon-large"></i> Borrow Table</strong>
</div>
<div class="span12">
<form method="post" action="borrow_save.php">
<div class="span3">
<div class="control-group">
<label class="control-label" for="inputEmail">Borrower Name</label>
<div class="controls">
<select name="member_id" class="chzn-select"required/>
<option></option>
<?php $result = mysql_query("select * from member")or die(mysql_error());
while ($row=mysql_fetch_array($result)){ ?>
<option value="<?php echo $row['member_id']; ?>"><?php echo $row['firstname']." ".$row['lastname']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">Due Date</label>
<div class="controls">
<input type="text" class="w8em format-y-m-d highlight-days-67 range-low-today" name="due_date" id="sd" maxlength="10" style="border: 3px double #CCCCCC;" required/>
</div>
</div>
<div class="control-group">
<div class="controls">
<button name="delete_student" class="btn btn-success"><i class="icon-plus-sign icon-large"></i> Borrow</button>
</div>
</div>
</div>
<div class="span8">
<div class="alert alert-success"><strong>Select Equipment</strong></div>
<table cellpadding="0" cellspacing="0" border="0" class="table" id="example">
<thead>
<tr>
<th>Acc No.</th>
<th>Equipment Description</th>
<th>Category</th>
<th>Quantity</th>
<th>status</th>
<th>Add</th>
</tr>
</thead>
<tbody>
<?php $user_query=mysql_query("select * from equipment where status != 'Archive' ")or die(mysql_error());
while($row=mysql_fetch_array($user_query)){
$id=$row['equipment_id'];
$cat_id=$row['category_id'];
$cat_query = mysql_query("select * from category where category_id = '$cat_id'")or die(mysql_error());
$cat_row = mysql_fetch_array($cat_query);
?>
<tr class="del<?php echo $id ?>">
<td><?php echo $row['equipment_id']; ?></td>
<td><?php echo $row['equipment_description']; ?></td>
<td><?php echo $cat_row ['classname']; ?> </td>
<td><?php echo $row['quantity']; ?> </td>
<?php /* <td><?php echo $row['equipment_description']; ?></td> */ ?>
<td width=""><?php echo $row['status']; ?></td>
<?php include('tooltip_edit_delete.php'); ?>
<td width="20">
<input id="" class="uniform_on" name="selector[]" type="checkbox" value="<?php echo $id; ?>" >
</td>
</tr>
<?php } ?>
</tbody>
</table>
</form>
</div>
</div>
<script>
$(".uniform_on").change(function(){
var max = 1;
if($(".uniform_on:checked").length < max){
$(".uniform_on:checked").attr('disabled', 'disabled');
alert('Please Check the item of equipment to be borrowed!');
$(".uniform_on:checked").removeAttr('disabled');
}else{
$(".uniform_on").removeAttr('disabled');
}
})
</script>
</div>
</div>
</div>
<?php include('footer.php') ?>
は変更を加えて、それは私がそれをデータベースに保存されません借りしたいトランザクション部分のために今の検証一部のために働くですjavascriptのための
<input name="delete_student" class="btn btn-success" type="button" value="Borrow" onClick="return validationfunction();" />
CODE:それはあなたが CODE新しいボローボタン借りてきたことだけ促さ
<script>
function validationfunction() {
if($(".uniform_on:checked").length > 0) {
alert('Equipment has been borrowed.');
return true
}
else {
alert('Please check the item of equipment to be borrowed!');
return false;
}
}
</script>
this i JavaScriptとjQuery、PHPではなく...また、私は0のajaxを参照してください。 – SpYk3HH
あなたの 'html'を表示してください –