Link to home
Start Free TrialLog in
Avatar of andrew201
andrew201

asked on

Prefilling values from database in dynamically added list boxes

I have an insert button. Whenever the user presses the button a list box is added. I want the list box to be prefilled with values from database(using a sql select statement).
Here is my code to add list boxes
<HTML>
<HEAD>
<script language="javascript">
//<!--
var TRCount =0;
var showCount=0;

function insRow()
{
    var x=document.getElementById('myTable').insertRow(TRCount)
    var y=x.insertCell(0)
    var z=x.insertCell(1)
    showCount = TRCount + 1
    y.innerHTML=showCount
    z.innerHTML="<SELECT NAME=''><option>1</option><option>2</option></SELECT>"
    TRCount++;
}


//-->
</script>

</HEAD>
<BODY>
       Class.forName("org.gjt.mm.mysql.Driver").newInstance();
     con=DriverManager.getConnection("jdbc:mysql://localhost/dbname");
     stmt=con.createStatement();
%>
 
<form name='form1' method='post'>
<table id="myTable">

</table>

<input type="button" onclick="insRow()" value="Insert Task">
</form>
            <center>
            </BODY>
</HTML>
ASKER CERTIFIED SOLUTION
Avatar of anthony_castillon
anthony_castillon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial