I've issue with checkbox in codeigniter. I Can't get Value from checkbox. I want to save only row cell with checkbox checked. So in controller I check whether the checkbox is checked or not. if checked save the data if not keep looking the checkbox with checked.
Please Help me to solve the issue. Thanks for your kindness
Best Regards,
Dian
This is my View
<!--<script>
$(function() {
var table = $('#MyTable').DataTable({
"lenghtMenu": [[5,10.20,-1],[5,10,20,"All"]]
});
$("#check_all").change(function() {
var checked = $(this).is(":checked");
alert(checked);
$("input", table.rows({ search: 'applied'}).nodes()).prop('checked', checked);
});
});
</script> -->
<div class="right_col" role="main">
<div class="">
<div class="page-title">
<div class="title_left">
<h3>Jual Asset Form</h3>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="clearfix"></div>
<div class="x_content">
<form class="form-horizontal form-label-left" method="POST" action="<?php echo base_url('assettrn/jualasset'); ?>">
<div class="item form-group">
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="perush">Perusahaan</label>
<div class="col-md-3 col-sm-3 col-xs-12">
<select class="select2_single form-control" tabindex="1" name="perush">
<option value="NULL"></option>
<?php foreach ($perushlov as $key => $value) { ?>
<option value="<?php echo $value['idper']?>"><?php echo $value['namaper']?></option>
<?php } ?>
</select>
</div>
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="lokasi">Lokasi Asset </label>
<div class="col-md-3">
<select class="select2_single form-control" tabindex="-1" name="lokasi">
<option value="NULL"></option>
<?php foreach ($lokasi as $key => $value) { ?>
<option value="<?php echo $value['idlokasi']?>"><?php echo $value['namalokasi']?></option>
<?php } ?>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="kategori">Kategori </label>
<div class="col-md-3">
<select class="select2_single form-control" tabindex="1" name="kategori">
<option value="NULL"></option>
<?php foreach ($kat as $key => $value) { ?>
<option value="<?php echo $value['idkategory']?>"><?php echo $value['namakategory']?></option>}
<?php } ?>
</select>
</div>
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="manufacture">Manufacture </label>
<div class="col-md-3">
<select class="select2_single form-control" tabindex="1" name="manufacture">
<option value="NULL"></option>
<?php foreach ($assetmanu as $key => $value) { ?>
<option value="<?php echo $value['manufacture']?>"><?php echo $value['manufacture']?></option>
<?php } ?>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="operan">Umur Asset</label>
<div class="col-md-1 col-sm-12 col-xs-12 form-group">
<select class="select2_single form-control" tabindex="-1" name="operan">
<option value="="> = </option>
<option value=">"> <?php echo ">" ?> </option>
<option value="<"> <?php echo "<" ?> </option>
<option value=">="> >= </option>
<option value="<="> <= </option>
</select>
</div>
<div class="col-md-1 col-sm-12 col-xs-12">
<input id="umurasset" class="form-control col-md-1 col-xs-12" name="umurasset" type="text"></input>
</div>
<label class="control-label" for="umurasset">Tahun</label>
</div>
<div class="item form-group">
<div class="col-md-7 col-sm-6 col-xs-12 col-md-offset-1">
<button type="submit" class="btn btn-info" name="view" value="view">View</button>
</div>
</div>
</div>
<!-- Header Jual -->
<div class="item form-group">
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="keterangan">Keterangan </label>
<div class="col-md-3">
<input id="ketjual" class="form-control col-md-1 col-xs-12" placeholder = "Required : Keterangan Jual Asset" name="ketjual" type="text"></input>
</div>
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="lokasi">Jual Ke PT </label>
<div class="col-md-3">
<select class="select2_single form-control" tabindex="-1" name="namaper">
<option value="NULL"></option>
<?php foreach ($perushlov as $key => $value) { ?>
<option value="<?php echo $value['idper']?>"><?php echo $value['namaper']?></option>
<?php } ?>
</select>
</div>
</div>
<div class="item form-group">
<div class="col-md-7 col-sm-6 col-xs-12 col-md-offset-1">
<button type="submit" class="btn btn-danger" name="jual" value="jual">Jual Asset</button>
</div>
</div>
</div>
<table class="table table-striped responsive-utilities " name="tbljual">
<thead style="font-size: small">
<tr class="headings">
<th class="column-title">No</th>
<th>
<!-- <input type="checkbox" id="check-all" class="flat"> -->
</th>
<th class="column-title">Perusahaan</th>
<th class="column-title">Kode Asset</th>
<th class="column-title">Kode Accounting</th>
<th class="column-title">Tgl Perolehan</th>
<th class="column-title">Umur Asset</th>
<th class="column-title">Kategori</th>
<th class="column-title">Nama Asset</th>
<th class="bulk-actions" colspan="7">
<a class="antoo" style="color:#fff; font-weight:300;">Bulk Actions ( <span class="action-cnt"> </span> ) <i class="fa fa-chevron-down"></i></a>
</th>
</tr>
</thead>
<tbody style="font-size: small">
<?php $cnt; foreach ($asset as $key => $value) { ?>
<tr>
<td><?php echo $cnt ?></td>
<td class="a-center ">
<input type="checkbox" class="flat" value = "0" name="sell[]">
</td>
<td><?php echo $value['dpj_asset_perush']; ?><input type = 'hidden' name="dpjper[]" value="<?php echo $value['dpjper'] ?>"></input></td>
<td><?php echo $value['idasset']; ?><input type = 'hidden' name="idasset[]" value="<?php echo $value['idasset'] ?>" ></input></td>
<td><?php echo $value['kodeasset']; ?><input type = 'hidden' name="kodeasset[]" value="<?php echo $value['kodeasset'] ?>" ></input></td>
<td><?php echo $value['tglperolehan']; ?><input type = 'hidden' name="tglperolehan[]" value="<?php echo $value['tglperolehan'] ?>" ></input></td>
<td><?php echo $value['umur_asset']; ?><input type = 'hidden' name="umur_asset[]" value="<?php echo $value['umur_asset'] ?>" ></input></td>
<td><?php echo $value['namakategory']; ?><input type = 'hidden' name="idket[]" value="<?php echo $value['idkategory'] ?>" ></input></td>
<td><?php echo $value['nama_asset']; ?><input type = 'hidden' name="nama_asset[]" value="<?php echo $value['nama_asset'] ?>" ></input></td>
</tr>
<?php $cnt++;} ?>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
this is my controller
<!--<script>
$(function() {
var table = $('#MyTable').DataTable({
"lenghtMenu": [[5,10.20,-1],[5,10,20,"All"]]
});
$("#check_all").change(function() {
var checked = $(this).is(":checked");
alert(checked);
$("input", table.rows({ search: 'applied'}).nodes()).prop('checked', checked);
});
});
</script> -->
<div class="right_col" role="main">
<div class="">
<div class="page-title">
<div class="title_left">
<h3>Jual Asset Form</h3>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="clearfix"></div>
<div class="x_content">
<form class="form-horizontal form-label-left" method="POST" action="<?php echo base_url('assettrn/jualasset'); ?>">
<div class="item form-group">
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="perush">Perusahaan</label>
<div class="col-md-3 col-sm-3 col-xs-12">
<select class="select2_single form-control" tabindex="1" name="perush">
<option value="NULL"></option>
<?php foreach ($perushlov as $key => $value) { ?>
<option value="<?php echo $value['idper']?>"><?php echo $value['namaper']?></option>
<?php } ?>
</select>
</div>
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="lokasi">Lokasi Asset </label>
<div class="col-md-3">
<select class="select2_single form-control" tabindex="-1" name="lokasi">
<option value="NULL"></option>
<?php foreach ($lokasi as $key => $value) { ?>
<option value="<?php echo $value['idlokasi']?>"><?php echo $value['namalokasi']?></option>
<?php } ?>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="kategori">Kategori </label>
<div class="col-md-3">
<select class="select2_single form-control" tabindex="1" name="kategori">
<option value="NULL"></option>
<?php foreach ($kat as $key => $value) { ?>
<option value="<?php echo $value['idkategory']?>"><?php echo $value['namakategory']?></option>}
<?php } ?>
</select>
</div>
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="manufacture">Manufacture </label>
<div class="col-md-3">
<select class="select2_single form-control" tabindex="1" name="manufacture">
<option value="NULL"></option>
<?php foreach ($assetmanu as $key => $value) { ?>
<option value="<?php echo $value['manufacture']?>"><?php echo $value['manufacture']?></option>
<?php } ?>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="operan">Umur Asset</label>
<div class="col-md-1 col-sm-12 col-xs-12 form-group">
<select class="select2_single form-control" tabindex="-1" name="operan">
<option value="="> = </option>
<option value=">"> <?php echo ">" ?> </option>
<option value="<"> <?php echo "<" ?> </option>
<option value=">="> >= </option>
<option value="<="> <= </option>
</select>
</div>
<div class="col-md-1 col-sm-12 col-xs-12">
<input id="umurasset" class="form-control col-md-1 col-xs-12" name="umurasset" type="text"></input>
</div>
<label class="control-label" for="umurasset">Tahun</label>
</div>
<div class="item form-group">
<div class="col-md-7 col-sm-6 col-xs-12 col-md-offset-1">
<button type="submit" class="btn btn-info" name="view" value="view">View</button>
</div>
</div>
</div>
<!-- Header Jual -->
<div class="item form-group">
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="keterangan">Keterangan </label>
<div class="col-md-3">
<input id="ketjual" class="form-control col-md-1 col-xs-12" placeholder = "Required : Keterangan Jual Asset" name="ketjual" type="text"></input>
</div>
<label class="control-label col-md-1 col-sm-3 col-xs-12" for="lokasi">Jual Ke PT </label>
<div class="col-md-3">
<select class="select2_single form-control" tabindex="-1" name="namaper">
<option value="NULL"></option>
<?php foreach ($perushlov as $key => $value) { ?>
<option value="<?php echo $value['idper']?>"><?php echo $value['namaper']?></option>
<?php } ?>
</select>
</div>
</div>
<div class="item form-group">
<div class="col-md-7 col-sm-6 col-xs-12 col-md-offset-1">
<button type="submit" class="btn btn-danger" name="jual" value="jual">Jual Asset</button>
</div>
</div>
</div>
<table class="table table-striped responsive-utilities " name="tbljual">
<thead style="font-size: small">
<tr class="headings">
<th class="column-title">No</th>
<th>
<!-- <input type="checkbox" id="check-all" class="flat"> -->
</th>
<th class="column-title">Perusahaan</th>
<th class="column-title">Kode Asset</th>
<th class="column-title">Kode Accounting</th>
<th class="column-title">Tgl Perolehan</th>
<th class="column-title">Umur Asset</th>
<th class="column-title">Kategori</th>
<th class="column-title">Nama Asset</th>
<th class="bulk-actions" colspan="7">
<a class="antoo" style="color:#fff; font-weight:300;">Bulk Actions ( <span class="action-cnt"> </span> ) <i class="fa fa-chevron-down"></i></a>
</th>
</tr>
</thead>
<tbody style="font-size: small">
<?php $cnt; foreach ($asset as $key => $value) { ?>
<tr>
<td><?php echo $cnt ?></td>
<td class="a-center ">
<input type="checkbox" class="flat" value = "2" name="sell[]">
</td>
<td><?php echo $value['dpj_asset_perush']; ?><input type = 'hidden' name="dpjper[]" value="<?php echo $value['dpjper'] ?>"></input></td>
<td><?php echo $value['idasset']; ?><input type = 'hidden' name="idasset[]" value="<?php echo $value['idasset'] ?>" ></input></td>
<td><?php echo $value['kodeasset']; ?><input type = 'hidden' name="kodeasset[]" value="<?php echo $value['kodeasset'] ?>" ></input></td>
<td><?php echo $value['tglperolehan']; ?><input type = 'hidden' name="tglperolehan[]" value="<?php echo $value['tglperolehan'] ?>" ></input></td>
<td><?php echo $value['umur_asset']; ?><input type = 'hidden' name="umur_asset[]" value="<?php echo $value['umur_asset'] ?>" ></input></td>
<td><?php echo $value['namakategory']; ?><input type = 'hidden' name="idket[]" value="<?php echo $value['idkategory'] ?>" ></input></td>
<td><?php echo $value['nama_asset']; ?><input type = 'hidden' name="nama_asset[]" value="<?php echo $value['nama_asset'] ?>" ></input></td>
</tr>
<?php $cnt++;} ?>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
Aucun commentaire:
Enregistrer un commentaire