我想问一下如何让我的表单正常工作 如果我点击“Tampilkan”我想去laporan_pasien,但如果我点击“Tampilkan PDF”我想去cetakdatapasien
<form action="<?=site_url("kepala_poliklinik/laporan_pasien");?>" method="post">
<form action="<?=site_url("kepala_poliklinik/cetakdatapasien");?>" method="post">
<div class="form-group">
<label>Nama : </label>
<input type="text" class="form-control" name="nama_h" id="nm_pasien" required>
<input type="hidden" name="nm_pasien" id="namehidden">
</div>
<div class="form-group">
<label>Date range : </label>
<div class="input-group">
<div class="input-group-addon">
<i class="glyphicon glyphicon-calendar"></i>
</div>
<input type="text" class="form-control" name="tgl_kunjungan" id="reservation" required/>
</div>
</div>
<div class="form-group">
<button class="btn btn-info btn-flat">Tampilkan</button>
</div>
</form>
<div class="form-group">
<button class="btn btn-info btn-flat" >Tampilkan PDF</button>
</div>
</form>
<?php
if(isset($datapasien)){
$data["datapasien"]=$datapasien;
$this->load->view("/kepala/tablepasien",$data);
}?>
答案 0 :(得分:0)
Use This :-
添加表单ID
<form action="" id="example_form" method="post">
在jquery中添加此代码
var site_url= "www.example.com";
$('#Tampilkan').click(function(){
$('#example_form').attr('action', site_url+'/Tampilkan');
});
$('#laporan_pasien ').click(function(){
$('#example_form').attr('action', site_url+'laporan_pasien');
});
答案 1 :(得分:0)
尝试将此事链接起来。
<div class="form-group">
<label>Nama : </label>
<input type="text" class="form-control" name="nama_h" id="nm_pasien" required>
<input type="hidden" name="nm_pasien" id="namehidden">
</div>
<div class="form-group">
<label>Date range : </label>
<div class="input-group">
<div class="input-group-addon">
<i class="glyphicon glyphicon-calendar"></i>
</div>
<input type="text" class="form-control" name="tgl_kunjungan" id="reservation" required/>
</div>
</div>
<div class="form-group">
<button class="btn btn-info btn-flat" onclick="2" name="sample">Tampilkan</button>
</div>
<div class="form-group">
<button class="btn btn-info btn-flat" name="sample1" >Tampilkan PDF</button>
</div>
</form>
<?php
if(isset($datapasien)){
$data["datapasien"]=$datapasien;
$this->load->view("/kepala/tablepasien",$data);
}
if(isset($_REQUEST['sample'])){
$this->load->view("yourfilename.ext",$data);
}
if(isset($_REQUEST['sample1'])){
$this->load->view("yourfilename1.ext",$data);
}
?>
答案 2 :(得分:0)
试试这个:
<form action="" id="form-submit" method="post">
<div class="form-group">
<label>Nama : </label>
<input type="text" class="form-control" name="nama_h" id="nm_pasien" required>
<input type="hidden" name="nm_pasien" id="namehidden">
</div>
<div class="form-group">
<label>Date range : </label>
<div class="input-group">
<div class="input-group-addon">
<i class="glyphicon glyphicon-calendar"></i>
</div>
<input type="text" class="form-control" name="tgl_kunjungan" id="reservation" required/>
</div>
</div>
<div class="form-group">
<button class="btn btn-info btn-flat" id="tampilkan">Tampilkan</button>
</div>
<div class="form-group">
<button class="btn btn-info btn-flat" id="tampilkanpdf">Tampilkan PDF</button>
</div>
</form>
<?php
if(isset($datapasien)){
$data["datapasien"]=$datapasien;
$this->load->view("/kepala/tablepasien",$data);
}?>
和jQuery代码:
<script>
$(function() {
$('#tampilkan').click(function(){
$('#form-submit').attr('action', '<?=site_url("kepala_poliklinik/laporan_pasien");?>');
$('#form-submit').submit();
});
$('#tampilkanpdf').click(function(){
$('#form-submit').attr('action', '<?=site_url("kepala_poliklinik/cetakdatapasien");?>');
$('#form-submit').submit();
});
});
</script>