esandra Posted November 2, 2010 Share Posted November 2, 2010 This script creates dynamic text boxes based on the chosen number from the drop down in php. But what I actually want to do is to use a drop down(generate comboboxes instead of the textboxes) that I want to populate with values from my sql table but I don't have any idea how to modify the javascript to do this... <html> <head> <script> function make_boxes(v) { v=!v?0:v; document.getElementById("boxes_container").innerHTML = ""; for(var i=0;i<v;i++){document.getElementById("boxes_container").innerHTML += "Box-"+(i+1)+": <input type='text' name='box"+i+"'><br />";} //the line above creates the text boxes } </script> </head> <body> <form action="" method=""> Pick number of boxes: <select name="numbers" onChange="make_boxes(this.value)"> //this where we choose the number <option value=""></option> <option value="5">5</option> <option value="10">10</option> <option value="30">30</option> <option value="50">50</option> </select> <p> <div id="boxes_container"><> //this is where the text boxes are displayed, also where i want to display the combo boxes </p> <p><input type="submit" value="Submit"></p> </form> </body> </html> thank you very much for your time and have a great day ahead of ya "Tag malfunction" edited . . . Quote Link to comment https://forums.phpfreaks.com/topic/217515-js-dropdown-must-populate-from-sql-table/ 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.