php - javascript from codeigniter into jsp -
i have method javascript in codeigniter when try put jsp, javascript doesn't work. in codeigniter, if call function, page refresh, when try put code jsp, function doesn't refresh page.
the code this:
<script type="text/javascript"> function submit_page(from){ var doc = document.frm_data; if(from == 1){ doc.tipe_lst.value = ""; doc.cab2_lst.value = ""; }else{ doc.wil_lst.value = ""; doc.cab_lst.value = ""; } doc.action = "<?php echo $page_action;?>"; doc.target=""; doc.submit(); }
i call codeigniter this:
<form name="frm_data" method="post"> <div style="float:left; position:relative; width:350px;"> <div> <label>kantor wilayah : </label> <select name="wil_lst" onchange="submit_page(1);"> <option value=""></option> <?php if(!empty($main_unit)){?> <?php foreach($main_unit $theitem): ?> <option value="<?php echo $theitem->kdwil;?>" <?php if($unit == $theitem->kdwil) echo "selected";?>><?php echo $theitem->unit_besaran;?></option> <?php endforeach; ?> <?php } ?> </select> </div> <div> <label>kantor cabang : </label> <select name="cab_lst" onchange="submit_page(1);"> <option value=""></option> <?php if(!empty($sub_unit)){?> <?php foreach($sub_unit $theitem): ?> <option value="<?php echo $theitem->unit_besaran;?>" <?php if($subunit == $theitem->unit_besaran) echo "selected";?>><?php echo $theitem->unit_besaran;?></option> <?php endforeach; ?> <?php } ?> </select> </div> </div> <div style="float:left; position:relative; width:350px; padding-left:20px; border-left:1px solid;"> <div> <label>tipe cabang : </label> <select name="tipe_lst" onchange="submit_page(2);" style="width:300px;"> <option value=""></option> <?php if(!empty($tipe_cabang)){?> <?php foreach($tipe_cabang $theitem): ?> <option value="<?php echo $theitem->status_cabang;?>" <?php if($tipe == $theitem->status_cabang) echo "selected";?>><?php echo $theitem->status_cabang;?></option> <?php endforeach; ?> <?php } ?> </select> </div> <div> <label>kantor cabang : </label> <select name="cab2_lst" onchange="submit_page(2);"> <option value=""></option> <?php if(!empty($sub_unit2)){?> <?php foreach($sub_unit2 $theitem): ?> <option value="<?php echo $theitem->unit_besaran;?>" <?php if($subunit2 == $theitem->unit_besaran) echo "selected";?>><?php echo $theitem->unit_besaran;?></option> <?php endforeach; ?> <?php } ?> </select> </div> </div> <div class="clear"></div> </form>
and when try put jsp, page doesn't refresh or send action of function submit_page this:
<form name="frm_data" method="post"> <div class="row"> <form role="form"> <div class="col-md-5 bg-default"> <div class="form-group"> <label for="a">kantor wilayah</label><br/> <select tabindex="1" name="tipe_lst" class="chosen-select" style="width: 240px;" onchange="submit_page(1);"> <option value="">pilih</option> <c:if test="${not empty main_unit}"> ${main_unit} </c:if> </select> </div> <div class="form-group"> <select tabindex="1" name="cab_lst" onchange="submit_page(1);" class="chosen-select" style="width: 350px;"> <option value="">pilih</option> <option value="1">kantor cabang balige</option> <option value="2">kantor cabang utama tanjung balai asahan</option> </select> </div> </div> <div class="col-md-5 bg-default"> <div class="form-group"> <label for="a">tipe cabang</label><br/> <select tabindex="1" class="chosen-select" style="width: 240px;" name="a" id="a"> <option value="">pilih</option> <option value="1">kantor wilayah medan</option> <option value="2">kantor wilayah padang</option> </select> </div> <div class="form-group"> <select tabindex="4" class="chosen-select" style="width: 350px;" name="d" id="d"> <option value="">pilih</option> <option value="1">kantor cabang balige</option> <option value="2">kantor cabang utama tanjung balai asahan</option> </select> </div> </div> <div class="col-md-2 bg-greensea"> <div class="form-group"> <label for="c">pencarian pegawai <input type="text" class="form-control" id="input01"> </label> </div> <div class="form-group"> <button type="submit" class="btn btn-rounded btn-slategray btn-md">search</button> </div> </div> </form> </div> </form>
the page doesn't refresh. how fix it?
i think should use jsp code instead of php in java script
doc.action = "<?php echo $page_action;?>";
Comments
Post a Comment