jquery - Add dynamic input type on change of select box in spring mvc -


i have box have options "input","select","check","radion". on select of option, need populate corresponding html type like
if select input, populate <input type="text"/>
if select select , populate <select> box
if select input, populate <input type="checkbox"/> tag.

all things should dynamically.

how can add spring:form tag new generated html type. adding new values command object.

kindly suggest how can this.

thanks, rishi.

try :

<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();          } }); }); 

demo : http://jsfiddle.net/9nkvc/24/


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -