gpt4 book ai didi

javascript - 如果选择的值是 SMTH,则跨度/隐藏输入

转载 作者:行者123 更新时间:2023-12-01 03:54:31 25 4
gpt4 key购买 nike

我已经选择了选项并且有很多输入。如果我选择选项(例如“USER”),我需要跨越准备好的输入,如果选择另一个选项,我需要再次隐藏它。

<form class="form-signup" action="admin_users.php" method="POST" id="payment-form">

<div class="well well-sm">
<h3 class="form-signin-heading"> Create

<select id="selectlist" name="selectproduct" >
<option value="1">User</option>
<option value="2">Admin</option>
<option value="3">Smth else</option>
<option value="4">Smth else of else</option>

</select>
</h3>

<div class="form-group">
<div class="col-xs-12">
<input class="form-control" type="text" name="username" id="username" placeholder="İstifadəçi" value="first input" required autofocus>
</div>
<div> &nbsp </div>
<div class="col-xs-12">
<input type="text" class="form-control" id="fname" name="fname" placeholder="Ad" value="second input" required>
</div>
<div> &nbsp </div>

<input class='btn btn-primary' type='submit' name='addUser' value='Create user' />
</div>
</form>

最佳答案

$( "#selectlist" ).change(function(event) {
if (this.value == 1 || this.value == 2) {
$(".form-control").show();
} else {
$(".form-control").hide();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form class="form-signup" action="admin_users.php" method="POST" id="payment-form">

<div class="well well-sm">
<h3 class="form-signin-heading"> Create

<select id="selectlist" name="selectproduct" >
<option value="1">User</option>
<option value="2">Admin</option>
<option value="3">Smth else</option>
<option value="4">Smth else of else</option>

</select>
</h3>

<div class="form-group">
<div class="col-xs-12">
<input class="form-control" type="text" name="username" id="username" placeholder="İstifadəçi" value="first input" required autofocus>
</div>
<div> &nbsp </div>
<div class="col-xs-12">
<input type="text" class="form-control" id="fname" name="fname" placeholder="Ad" value="second input" required>
</div>
<div> &nbsp </div>

<input class='btn btn-primary' type='submit' name='addUser' value='Create user' />
</div>
</form>

关于javascript - 如果选择的值是 SMTH,则跨度/隐藏输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42880694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com