【发布时间】:2015-10-12 05:32:34
【问题描述】:
我正在尝试 ajax 提交 PHP 表单,它工作正常。 现在无论来自 PHP 的结果都存储在 div 中。我希望打印该结果。
这里是代码,
<label>Customer. :</label>
<select type="text" class="form-control required" id="customer" name="customer" onChange="get_part(this)">
<option value="">Select Customer </option>
<?php
foreach($customer_data as $ss){
?>
<option value="<?php echo $ss['customer_id'] ;?>"
<?php if($edit_data!=NULL && $edit_data['customer']== $ss['customer_id']){echo "selected=selected";}?>><?php echo $ss['name'] ;?>
</option>
<?php
}
?>
</select>
</div>
<div class="col-lg-10 col-xs-4 form-group">
<label>Part no. :</label>
<select type="text" class="form-control required" id="part" name="part" onChange="get_lotno(this)">
<option value="">Select Part no</option>
<?php
foreach($parts_data as $pp){
?>
<option value="<?php echo $pp['part_id'] ;?>"
<?php if($edit_data!=NULL && $edit_data['part']== $pp['part_id']){echo "selected=selected";}?>><?php echo $pp['part_no'] ;?>
</option>
<?php
}
?>
</select>
</div>
<div class="col-lg-10 col-xs-4 form-group">
<label>Lot No. :</label>
<select type="text" class="form-control required" id="order_id" name="order_id" onChange="get_lotdetails(this)">
<option value="">Select Lot No</option>
</select>
</div>
<div class="col-lg-5 col-xs-4 form-group">
<label>Lot Quantity :</label>
<input type="text" name="lotqnty" id="lotqnty" class="form-control" readonly>
</div>
<div class="col-lg-5 col-xs-4 form-group">
<label>Lot Rem. Qty :</label>
<input type="text" name="lotremqnty" id="lotremqnty" class="form-control" readonly>
</div>
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<button type="submit" id="submit" class="btn btn-primary">Start Test</button>
</div>
</div><!-- /.box -->
</form>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header"></div><!-- /.box-header -->
<div class="box-body" id="table_div">
</div><!-- /.box-body -->
</div><!-- /.box -->
</div><!-- /.col -->
</div><!-- /.row -->
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<?php $this->load->view('admin/pages/footer.php') ?>
</div><!-- ./wrapper -->
<script type="text/javascript">
$(function () {
$("#form").validate({
rules: {
customer: {required: true},
part: {required: true}
},
submitHandler: function(form) {
$.ajax({
type: "POST",
url:'<?php echo base_url()?>admin/test/createSave',
data:'&customer_id='+$("#customer").val()+'&order_id='+$("#order_id").val()+'&part_id='+$("#part").val(),
cache: false,
async:false,
beforeSend : function ()
{
$("#submit").addClass("disabled");
$("#table_div").html('<div align="center"><img src="<?=base_url()?>admindata/dist/img/table_loader.GIF"></div>');
},
success: function (data) {
$("#ajax_loader").hide();
$("#table_div").html(data);
$("#lotremqnty").val($("#rem_lot_qty").val());
$("#submit").removeClass("disabled");
});
});
标签打印成功后表格格式的内容。
任何人都可以帮助我通过 PHP 打印标签。
标签打印机:东芝 B-EV4T
提前致谢
【问题讨论】:
-
像 $('#id-label').text('YOur label value') 一样使用。
-
我正在显示它,我希望它用于打印机打印
-
参考这个链接:stackoverflow.com/questions/11215151/ajax-print-page-content
-
请给我的答案投票并标记为接受。