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.Driv er").newIn stance();
con=DriverManager.getConne ction("jdb c: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>
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(
var y=x.insertCell(0)
var z=x.insertCell(1)
showCount = TRCount + 1
y.innerHTML=showCount
z.innerHTML="<SELECT NAME=''><option>1</option>
TRCount++;
}
//-->
</script>
</HEAD>
<BODY>
Class.forName("org.gjt.mm.
con=DriverManager.getConne
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.