am using JS in Servlet..
My JS is
out.println(" <script language='javascript'> ");

//out.println("window.history.go(+1);");


out.println(" var gRowId = 2; ");
out.println(" var i=2;");
out.println(" function delRow(button) ");
out.println(" { var row = button.parentNode.parentNode; ");
out.println("var tbody = document.getElementById('table1').getElementsByTagName('tbody')[0]; ");
out.println("tbody.removeChild(row); ");
out.println("--i;");
out.println(" } ");
out.println(" function addRow() ");
out.println(" { ");
out.println("var tbody = document.getElementById('table1').getElementsByTagName('tbody')[0]; ");
out.println("var row = document.createElement('TR'); ");

//cell1
out.println("var cell1 = document.createElement('TD'); ");
out.println("cell1.setAttribute('align','center');");
out.println("cell1.setAttribute('height','35');");
out.println("var inp1 = document.createElement('INPUT'); ");
out.println("inp1.setAttribute('type','text'); ");
out.println("inp1.setAttribute('name','slno'); ");
out.println("inp1.setAttribute('value',i); ");
out.println("inp1.setAttribute('size','3'); ");
out.println("cell1.appendChild(inp1); ");

//cell2
out.println("var cell2 = document.createElement('TD'); ");
out.println("cell2.setAttribute('height','35');");
out.println("cell2.setAttribute('align','center');");
out.println("cell2.innerHTML=\"<select name='medicine_name' >\" +");

//THIS IS THE CODE USED IN JAVA

/* y="select med_name from med_details";
rs=st.executeQuery(y);
while (rs.next())
{
med_name=rs.getString(1);
out.println(" <option value='"+med_name+"'>"+med_name+"</option>");
}*/


out.println("\" <option value='crocin'>crocin</option>\" +");
out.println(" \"<option value='corex'>corex</option>\" +");
out.println(" \" <option value='ibrufin'>ibrufin</option>\" +");
out.println(" \" <option value='nise'>nise</option>\" +");
out.println(" \" <option value='avil'>avil</option>\" +");
out.println(" \" <option value='okacis'>okacis</option>\" +");
out.println(" \" <option value='omaze'>omaze</option>\" +");
out.println(" \" <option value='seumol'>seumol</option>\" +");
out.println(" \" <option value='coldarin'>coldarin</option>\" +");
out.println(" \" </select>\" ;");

//cell3
out.println("var cell3 = document.createElement('TD'); ");
out.println("cell3.setAttribute('height','35');");
out.println("cell3.setAttribute('align','center');");
out.println("var inp3 = document.createElement('INPUT'); ");
out.println("inp3.setAttribute('type','text'); ");
out.println("inp3.setAttribute('name','quantity'); ");
out.println("inp3.setAttribute('size','5'); ");
out.println("cell3.appendChild(inp3); ");


//cell4
out.println("var cell4 = document.createElement('TD'); ");
out.println("cell4.setAttribute('height','35'); ");
out.println("var inp4 = document.createElement('INPUT'); ");
out.println("inp4.setAttribute('type','button'); ");
out.println("inp4.setAttribute('value','Delete'); ");
out.println("inp4.onclick=function(){delRow(this);} ");
out.println("cell4.appendChild(inp4); ");

out.println("row.appendChild(cell1); ");
out.println("row.appendChild(cell2); ");
out.println("row.appendChild(cell3);");
out.println("row.appendChild(cell4); ");
out.println("tbody.appendChild(row); ");
out.println("i++;");
out.println(" } ");
out.println(" </script> ");


and My Servlet code is

// BELOW LINE IS FOR CALLING JS TO ADD A DYNAMIC ROW......

out.println(" <td width='25%' height='21' align='center'><input type='button' value='Add record' name='Add Column' onClick='addRow();'></td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td width='25%' height='21' align='center'><input type='text' name='slno' size='3' value='1'></td>");
out.println(" <td width='25%' height='21' align='center'><select size='1' name='medicine_name'>");

// I USED THIS QUERY TO GENERATE MEDICINE NAME DYNAMICALLY......

/* y="select med_name from med_details";
rs=st.executeQuery(y);
while (rs.next())
{
med_name=rs.getString(1);
out.println(" <option value='"+med_name+"'>"+med_name+"</option>");
}
*/
out.println(" <option value='crocin'>crocin</option>");
out.println(" <option value='corex'>corex</option>");
out.println(" <option value='ibrufin'>ibrufin</option>");
out.println(" <option value='nise'>nise</option>");
out.println(" <option value='avil'>avil</option>");
out.println(" <option value='okacis'>okacis</option>");
out.println(" <option value='omaze'>omaze</option>");
out.println(" <option value='seumol'>seumol</option>");
out.println(" <option value='coldarin'>coldarin</option>");
out.println(" </select></td>");
out.println(" <td width='25%' height='21' align='center'><input type='text' name='quantity' size='5'></td>");

out.println(" <input type='hidden' name='Staff_no' value='"+staffno+"'>");

out.println(" <td width='25%' height='21' align='center'></td>");
out.println(" </tr>");

out.println(" </table>");
out.println(" </center>");
out.println("</div>");
out.println(" <div align='center'>");
out.println(" <center>");
out.println(" <table border='0' cellpadding='0' cellspacing='0' width='100%' height='90'>");
out.println(" <tr>");
out.println(" <td width='100%' height='21' colspan='4' align='center'><input type='submit' value='Continue' name='B1'></td>");
out.println(" </tr>");

out.println(" </table>");
out.println(" </center>");
out.println("</div>");


How can i connect JS to SQL?

This is Because for adding multiple records, I need to get medicine names from the database in a list box...

That is exactly below CELL2 in the JAVA SCRIPT...