Solarpitch Posted March 29, 2010 Share Posted March 29, 2010 Hey, Just wondering how I can achieve this as my JS skills arn't that great. I have a drop down with 10 values from 1 - 10. If the user selects 3 from the dropdown I want to append 3 textfields below it.. if they choose 5 .. it appends 5 textfields and so on. I'm trying to achieve this with JQuery but not having much luck. Quote Link to comment Share on other sites More sharing options...
andrewgauger Posted March 29, 2010 Share Posted March 29, 2010 <script language="javascript"> function makeBoxes(){ var divElement=document.getElementById("dynamicText") var textHTML=""; var element=document.getElementById("selectBox") for (var i=0; i<element.options.length; i++){ if (element.options[i].selected==true){ textHTML=textHTML+"<input type='textbox' Name='"+i+"' Id='"+i+"'>" } } divElement.innerHTML=textHTML; } </script> <form name="testform"> <select multiple id="selectBox" size="2" width="100" onClick="javascript:makeBoxes()"> <option value="first">first <option value="second">second <option value="third">third <option value="fourth">fourth <option value="fifth">fifth <option value="sixth">sixth </select> <div id="dynamicText"></div> </form> I like the way you think Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.