使用QRCODE扫描仪扫描值后打开BOOTSTRAP模式



我有一个表单,当用户将他们的二维码扫描到扫描仪中时,会弹出一个包含他们详细信息的模态。

上次我用这个解决方案成功地做到了。如何在通过条形码扫描仪提交表单后打开引导模式框

但现在,它已经不起作用了。

这是我的代码

<form name = "auto_barcode" id="auto_barcode" action="" method="post"> 
<div class="form-group center">
<label class="label-material active" style="font-color: #4b0082; ">ID number</label>
<input id="employee_qrcode" type="password" name="employee_qrcode" required="" class="form-control center" autofocus placeholder="Type your employee ID number here">
</div>
</form>

我的模式:

<div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" aria-hidden="true" class="modal fade text-left">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header primary-bg">
<h4 id="exampleModalLabel" class="modal-title" style="color: white;">online health declaration form </h4>
</div>
<div class="modal-body">
<div class="form-group row"> 
<input id="employee_qrcode1" type="text" class="form-control form-control-success " value="" disabled hidden="true" >
<label  class="col-md-12 form-control-label" style="font-size: 30px; font-weight: bold; margin-left: 20px; " id="info_employee_name" type="text" ></label> 
<label class="col-md-12 form-control-label" id="info_employee_address" type="text" style="font-weight: bold; font-size: 15px; margin-left: 20px; ">Km. 38 B, Balasing Road, Pulong Buhangin, Santa Maria, Bulacan</label>
<label class="col-md-12 form-control-label" id="info_employee_contactNo" style="font-weight: bold; font-size: 15px; margin-left: 20px; " type="text" >0915-333-5984</label>
<label class="col-md-12 form-control-label" id="info_employee_section" style="font-weight: bold; font-size: 15px;margin-left: 20px; " type="text" >RICTMS</label>
</div>  
<div class="row">
<div class="col-lg-12">
<div class="card-body">
<div class="form-group row">
<label class="col-md-8 form-control-label"  style="font-weight: bold;">Body Temperature:</label>
<div class="col-md-10">
<input id="body_temperature" type="text" class="form-control form-control-success" style="resize: none; color: blue; text-transform: uppercase;" name="body_temperature"/>
</div>
</div>
<div class="form-group row">
<label class="col-md-8 form-control-label"  style="font-weight: bold;">Places visted and transited within the last 14 days:</label>
<div class="col-md-10">
<input id="place_visited14" type="text" class="form-control form-control-success" style="resize: none; color: blue; text-transform: uppercase;" name="place_visited14"/>
</div>
</div>
<div class="form-group row">
<label class="col-md-8 form-control-label"  style="font-weight: bold;">Have you been hospitalized for the past 14 days?</label>
<div class="col-md-10">
<div class="custom-control custom-radio">
<input type="radio" name="is_hospitalized" value="YES" /> YES <br>
Please describe condition.<br>
<input id="employee_condition_hospitalized" type="text" class="form-control form-control-success" style="resize: none; color: blue; text-transform: uppercase;" name="employee_condition_hospitalized"><br>
</div>
</div>
<div class="col-md-10">
<div class="custom-control custom-radio">
<input type="radio" checked="true" name="is_hospitalized" value="NO"/> No 
</div>
</div>
</div>
<div class="form-group row">
<label class="col-md-8 form-control-label"  style="font-weight: bold;">In the last 14 days, did you have any of the following : Fever, Colds, Cough, Sore Throat or Difficulty in Breathing?</label>
<div class="col-md-10">
<div class="custom-control custom-radio">
<input type="radio" name="is_symptoms" value="YES"/> YES <br>
Please specify.<br>
<input id="employee_condition_symptoms" type="text" class="form-control form-control-success" style="resize: none; color: blue; text-transform: uppercase;" name="employee_condition_symptoms"><br>
</div>
</div>
<div class="col-md-10">
<div class="custom-control custom-radio">
<input type="radio" checked="true" name="is_symptoms" value="NO"/> No 
</div>
</div>
</div>
<div class="form-group row">
<label class="col-md-8 form-control-label"  style="font-weight: bold;">Have you been identified as PUM/PUI?</label>
<div class="col-md-10">
<div class="custom-control custom-radio">
<input type="radio" name="is_pui" value="YES"/> YES
</div>
</div>
<div class="col-md-10">
<div class="custom-control custom-radio">
<input type="radio" checked="true" name="is_pui" value="NO"/> No 
</div>
</div>
</div>
<div class="form-group row">
<label class="col-md-8 form-control-label"  style="font-weight: bold;">Have you been in direct contact with or within the immediate vicinity of any person known to be a PUM/PUI?</label>
<div class="col-md-10">
<div class="custom-control custom-radio">
<input type="radio" name="is_contact" value="YES"/> YES
</div>
</div>
<div class="col-md-10">
<div class="custom-control custom-radio">
<input type="radio" checked="true" name="is_contact" value="NO"/> No 
</div>
</div>
</div>
</div>
</div>
</div> 
</div>
<div class="modal-footer">
<div class="form-group row">       
<div class="col-md-12">
<label><u>DECLARATION AND DATA PRIVACY CONSENT FORM:</u><br><br>
The information I have given is true, correct and complete. I understand that failure to answer any question or giving false answer can be penalized in accordance with law. I voluntarily and freely consent the collection and sharing of the above personal information only in the relation to the office safety protocols.</label>
<!-- <input type="submit" style="float:right" class="btn btn-primary" value="Save" id="btnSave"> -->
<button type="submit" id="btnSave" class="btn btn-success float-right btnSave" >Submit</button>
<button type="button" style="float:right; margin-right:10px;" class="btn btn-dark cancelBtn" data-dismiss="modal" aria-label="Close">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>

我的javascript:

$('#auto_barcode').submit(function () {
event.preventDefault();
var employee_qrcode = document.getElementById("employee_qrcode").value;
// var employee_qrcode = $(this).data('value');
$.ajax({
type: 'post',
url: base_url+'Main_scan/ohdf_employee_details',
data: {'employee_qrcode': employee_qrcode},
success: function(data){
var res1 = data.result1;
if(data.success==1){
document.getElementById('info_employee_name').innerHTML= res1[0].employee_fname+" "+res1[0].employee_mname+" "+res1[0].employee_lname;
document.getElementById('info_employee_contactNo').innerHTML= "Contact Number:  "+res1[0].employee_contact_nop;
document.getElementById('info_employee_address').innerHTML= "Address: "+res1[0].employee_address;
document.getElementById('info_employee_section').innerHTML = "Division/Section/Unit:  "+res1[0].employee_section;
$('#myModal').modal();
} // add else toast here....
}
});
});

模态只有在我按下回车键时才起作用,但特别是我需要在扫描ng QRcode后显示它。

我已经得到了问题的解决方案!我只是将我的二维码扫描仪恢复到出厂默认设置。我的代码没有问题。:(

最新更新