Jump to content

js dropdown must populate from sql table


esandra

Recommended Posts

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 . . .

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.