我有两个下拉菜单,如果更改下拉菜单的值,它会影响到另一个下拉菜单(自动更改下拉菜单的值2)如何解决此问题。
<!--5 pannel starts-->
<div class="panel panel-default">
<div class="panel-heading row">
<div class="col-md-4 col-sm-4 col-xs-4">Country</div>
<div class="col-md-4 col-sm-4 col-xs-4 ellipsis" id="ccountry"><?php
if (isset($s_country)) {
echo $s_country;
}
?>
</div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapse5">
<div class="profile-edit col-sm-4 col-xs-4 col-md-4 aj-textfive">
<?php if (empty($s_country[0]) || empty($s_country)): ?>
Add
<?php else: ?>
<i class="fa fa-pencil"></i> Edit
<?php endif; ?>
</div>
</a>
</div>
<div id="collapse5" class="panel-collapse collapse">
<div class="panel-body">
<div class="row">
<div class="col-md-7 col-lg-offset-2 text-center">
<label class="col-md-4">Country</label>
<div class="col-md-8">
<select name="country" id="country" class="form-control"
value="<?= (isset($s_country)) ? $s_country : null; ?>"><br>
<option value="india">india</option>
<option value="aus">aus</option>
</select>
<input type="hidden" name="save_country" id="save_country" value="<?= (empty($s_country[0]) || empty($s_country)) ? 'Save' : 'Update'; ?>">
<?php if (empty($s_country[0]) || empty($s_country)): ?>
<button type="submit" class="btn btn-success aj-text-btnfive" data-target="#collapse5" data-toggle="collapse">Save</button>
<?php else: ?>
<button type="submit" class="btn btn-success aj-text-btnfive" data-target="#collapse5" data-toggle="collapse">Update</button>
<?php endif; ?>
<button type="button" data-target="#collapse5" data-toggle="collapse" class="btn btn-warning cancel-name">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!--5 pannel ends-->
<!--6 pannel starts-->
<div class="panel panel-default">
<div class="panel-heading row">
<div class="col-md-4 col-sm-4 col-xs-4">State</div>
<div class="col-md-4 col-sm-4 col-xs-4 ellipsis" id="cstate"><?php
if (isset($s_state)) {
echo $s_state;
}
?>
</div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapse6">
<div class="profile-edit col-sm-4 col-xs-4 col-md-4 aj-textsix">
<?php if (empty($s_state[0]) || empty($s_state)): ?>
Add
<?php else: ?>
<i class="fa fa-pencil"></i> Edit
<?php endif; ?>
</div>
</a>
</div>
<div id="collapse6" class="panel-collapse collapse">
<div class="panel-body">
<div class="row">
<div class="col-md-7 col-lg-offset-2 text-center">
<label class="col-md-4">State</label>
<div class="col-md-8">
<select name="state" id="state" type ="text" class="form-control"
value="<?= (isset($s_state)) ? $s_state : null; ?>"><br>
<option value="indiaa">indiaa</option>
<option value="aussss">aussss</option>
</select>
<input type="hidden" name="save_state" id="save_state" value="<?= (empty($s_state[0]) || empty($s_state)) ? 'Save' : 'Update'; ?>">
<?php if (empty($s_state[0]) || empty($s_state)): ?>
<button type="submit" class="btn btn-success aj-text-btnsix" data-target="#collapse6" data-toggle="collapse">Save</button>
<?php else: ?>
<button type="submit" class="btn btn-success aj-text-btnsix" data-target="#collapse6" data-toggle="collapse">Update</button>
<?php endif; ?>
<button type="button" data-target="#collapse6" data-toggle="collapse" class="btn btn-warning cancel-name">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!--6 pannel ends-->
ajax电话
$(".aj-textfive").html(result.replace_textfive); $(".aj-text-btnfive").html(result.btn_textfive); $("#save_country").val(result.save_country); $('#ccountry').text($("#country").val());
$(".aj-textsix").html(result.replace_textsix);
$(".aj-text-btnsix").html(result.btn_textsix);
$("#save_state").val(result.save_state);
$('#cstate').text($("#state").val());
答案 0 :(得分:1)
只需替换以下代码
<select name="state" id="state" type ="text" class="form-control"
value="<?= (isset($s_state)) ? $s_state : null; ?>"><br>
<option value="<?php echo $s_state; ?>">--select--</option>
<option value="indiaa">indiaa</option>
<option value="aussss">aussss</option>
</select>