这是我的HTML代码:
<div class="full Mtop2">
<div class="col-6">
<div class="col-8">
<div class="col-6 label">
<label>City</label>
</div>
<div class="col-6-m feild">
<select name="selfaclcity[]" id="selfaclcity">
<option value=""> --- Select --- </option>
</select>
</div>
</div>
<div class="col-4-m">
<div class="col-4 label">
<label>State</label>
</div>
<div class="col-8-m feild">
<select name="selfaclstate[]" id="selfaclstate">
<option value="">--Select--</option>
</select>
</div>
</div>
</div>
<div class="col-6-m">
<div class="col-7 label">
<label>Zip Code</label>
</div>
<div class="col-5-m feild">
<input type="text" id="txtfaclzipcode" value="" name="txtfaclzipcode[]">
</div>
</div>
</div>
<div class="col-6">
<div class="col-7 label">
<label>Multiple Facility Owners?</label>
</div>
<div class="col-5-m feild">
<select name="selmulti_owner[]" id="selmulti_owner" class="selmulti_owner">
<option value="10"> --- Please Select --- </option>
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
</div>
以下是我从数据库中选择状态的代码:
var url = "<?php echo 'inc/getstate.php' ?>";
var getstate = "getstate";
$.post(url,{'getstate':getstate},function(msg){
$('#selstate').append(msg);
$('#selfaclstate').append(msg);
$('#selcurfaclstate').append(msg);
});
这是我生成动态输入字段(.JS Page)的代码
$( document ).on( "change", ".selmulti_owner", function() {
if($(this).val() == 1){
var i=$('.multi_facility').length;
var url = "../inc/getstate.php";
var getstate = "getstate";
$.post(url,{'getstate':getstate},function(msg){
$('#selfaclstate'+i).html(msg);
});
$html ='';
$html += '<div class="full multi_facility">';
$html += '<div class="col-6 label">';
$html += '<label> Additional City</label>';
$html += '</div>';
$html += '<div class="col-6-m feild">';
$html += '<select name="selfaclcity[]" id="selfaclcity">';
$html += '<option value=""> --- Select --- </option>';
$html += '</select>';
$html += '</div>';
$html += '</div>';
$html += '<div class="col-6-m">';
$html += '<div class="col-6 label">';
$html += '<label>Additional State</label>';
$html += '</div>';
$html += '<div class="col-6-m feild">';
$html += '<select name="selfaclstate[]" id="selfaclstate">';
$html += '<option value="NY">New York</option>';
$html += '</select>';
$html += '</div>';
$html += '<div class="col-6-m">';
$html += '<div class="col-7 label">';
$html += '<label>Additional Zip Code</label>';
$html += '</div>';
$html += '<div class="col-5-m feild">';
$html += '<input type="text" id="txtfaclzipcode" value="" name="txtfaclzipcode[]">';
$html += '</div>';
$html += '</div>';
$html += '</div>';
$html += '<div class="facility_minus Mtop2"><i class="fa fa-minus fa-2x"></i></div>';
$html += '</div>';
$('.Facility_add').append($html);
}
});
以下是从我的数据库生成状态字段。当我选择一个州的相应城市显示在城市领域时,我在一个选项中选择一个城市,其相应的邮政编码显示在相应的邮政编码字段中。
在我的第二步中,我选择多个设施所有者?如果我选择是显示其他一些字段。但是州不会出现在州立大学的领域。初始状态它的工作但动态生成的状态字段不起作用。
请帮助我。