根据下拉选择显示字段集 yii 2
Display field set based on dropdown selection yii 2
我是 javacripting 和 Yii2 Framework 的新手。谁能帮我根据下拉选择显示一组字段值。
例如,我在下拉列表中有“你是不是学生?”:
- 是
- 否
如果用户选择 是,则显示 div 包含其他要回答的字段。
我可以找到一般情况下的答案,但特别是使用 Yii 2 我遇到了问题。
提前致谢。
这对于 jquery 来说非常简单...您可以通过多种方式做到这一点,但这里有一个示例:
//HTML
<input type="radio" name="student" id="studentY" /> Yes
<input type="radio" name="student" id="studentN" /> No
<div id="moreQuestions">
<p>This is your block containing more fields</p>
</div>
//JS
$('#studentY').click(function(){
$('#moreQuestions').show();
});
$('#studentN').click(function(){
$('#moreQuestions').hide();
});
我是 javacripting 和 Yii2 Framework 的新手。谁能帮我根据下拉选择显示一组字段值。
例如,我在下拉列表中有“你是不是学生?”:
- 是
- 否
如果用户选择 是,则显示 div 包含其他要回答的字段。
我可以找到一般情况下的答案,但特别是使用 Yii 2 我遇到了问题。
提前致谢。
这对于 jquery 来说非常简单...您可以通过多种方式做到这一点,但这里有一个示例:
//HTML
<input type="radio" name="student" id="studentY" /> Yes
<input type="radio" name="student" id="studentN" /> No
<div id="moreQuestions">
<p>This is your block containing more fields</p>
</div>
//JS
$('#studentY').click(function(){
$('#moreQuestions').show();
});
$('#studentN').click(function(){
$('#moreQuestions').hide();
});