我有一个框,它有“输入”、“选择”、“检查”、“辐射”等选项。在选择任何选项时,我需要填充相应的html类型,如
如果我选择输入,我想填充<input type="text"/>
如果选择,则希望填充<select> box
如果选择输入,则希望填充<input type="checkbox"/>标记。
所有这些事情都应该是动态的。
如何为新生成的html类型添加spring:form标记。因此,我将将新值添加到命令对象中。
请建议我怎么做这件事。
谢谢,瑞西。
发布于 2014-06-26 09:20:28
试试这个:
<select id="multiOptions" name="multiOptions" style="width: 214px">
 <option value="S" selected="selected">--Select Input Type --</option>
<option value="C">Checkbox</option>
<option value="R">Radio</option>
<option value="B">Button</option>
</select>
<div id="radios">
    <input type="radio" value="1" name="option">option1</input>
    <input type="radio" value="2" name="option">option2</input>
</div>
<div id="checkboxes">
    <input type="checkbox" value="1" name="option">option1</input>
    <input type="checkbox" value="2" name="option">option2</input>
</div>
<div id="buttons">
    <input type="button" value="option1" name="option"/>
    <input type="button" value="option2" name="option"/>
</div>jquery:
$(document).ready(function () {
$('#checkboxes').hide();
$('#radios').hide();
$('#buttons').hide();
$("#multiOptions").change(function () {
    if ($(this).val() == "R" ) {
       $('#radios').show();
       $('#checkboxes').hide();
       $('#buttons').hide();
    }
 else if ($(this).val() == "C") {
     $('#checkboxes').show();
     $('#radios').hide();
     $('#buttons').hide();
    }
    else if ($(this).val() == "B"){
     $('#checkboxes').hide();
     $('#radios').hide();
     $('#buttons').show();
    }
    else { 
        $('#checkboxes').hide();
        $('#radios').hide(); 
        $('#buttons').hide();
         }
});
});演示:http://jsfiddle.net/9NkVC/24/
https://stackoverflow.com/questions/24425990
复制相似问题