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. Link to comment https://forums.phpfreaks.com/topic/196876-appending-an-input-field-froma-dropdown/ 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 Link to comment https://forums.phpfreaks.com/topic/196876-appending-an-input-field-froma-dropdown/#findComment-1033645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.