Reputation: 43
I want to add the time variable when sending data with javascript
$(function() {
$("#cetak").click(function(){
var kode = $('#noanggota').val();
var id = $(".id:checked").val();
var jml_id = $(".id:checked");
if(jml_id.length == 0){
var error = false;
alert("Maaf, Anda belum memilih");
//$("#txt_user").focus();
return (false);
}
window.open("<?php echo base_url();?>index.php/persetujuan_pinjaman?x=1&"+id+"="+kode);
};
Html code:
<table width="100%">
<tr>
<td><input type="radio" name="id" class="id" value="id" checked /> Masukan Nomor Anggota</td>
<td><input type="text" name="noanggota" id="noanggota" /></td>
</tr>
</table>
how I want add variable date with this code ??
window.open("<?php echo base_url();?>index.php/persetujuan_pinjaman?x=1&"+id+"="+kode);
Upvotes: 1
Views: 125
Reputation: 9635
user js calender in your form as input box.
link http://javascriptcalendar.org/javascript-date-picker.php
download it and apply in your form also document is there.
now in your js read the value of date input box as you read input "noanggota"
and make url. hope you find the answer.
Upvotes: 0
Reputation: 22741
Your code not properly closed with });
$(function() {
$("#cetak").click(function(){
var kode = $('#noanggota').val();
var id = $(".id:checked").val();
var jml_id = $(".id:checked");
var mydate = new Date(year, month [, day, hour, minute, second, millisecond]);
if(jml_id.length == 0){
var error = false;
alert("Maaf, Anda belum memilih");
//$("#txt_user").focus();
return (false);
}
window.open("<?php echo base_url();?>index.php/persetujuan_pinjaman?x=1&"+id+"="+kode+"&mydate="+mydate);
});
});
For Date: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
Upvotes: 2