The code below will add new form elements when ever I click the add button. However when you add more elements the combo box element goes out of alignment. Try it out. Now is there a way to fix this problem?.
function addValue(divname){
var newdiv = document.createElement('div');
newdiv.innerHTML = "<BR><INPUT TYPE='text' name='index1'>";
document.getElementById(divname).appendChild(newdiv);
}
function addUnit(divname){
var newdiv = document.createElement('div');
newdiv.innerHTML = "<BR><select name='index2'><option value='gm'>gm</option><option value='liters'>liters</option><option value='ml'>ml</option><option value='kg'>kg</option></select>";
document.getElementById(divname).appendChild(newdiv);
}
function addDescription(divname){
var newdiv = document.createElement('div');
newdiv.innerHTML = "<BR><INPUT TYPE='text' name='index3'>"
document.getElementById(divname).appendChild(newdiv);
}
multientry.html
<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT SRC="multientry.js" LANGUAGE="Javascript" TYPE="text/javascript"></SCRIPT>
</HEAD>
<BODY>
<FORM method="post">
<TABLE>
<TR>
<TD>Measurement</TD>
<TD>Unit</TD>
<TD>Description</TD>
</TR>
<TR>
<TD><DIV id="input1"><INPUT TYPE="text" name="index1"></DIV></TD>
<TD><DIV id="input2"><select name="index2"><option value="gm">gm</option><option value="liters">liters</option><option value="ml">ml</option><option value="kg">kg</option></select>
</DIV></TD>
<TD><DIV id="input3"><INPUT TYPE="text" name="index3"></DIV></TD>
</TR>
<TR>
<TD COLSPAN="3"><INPUT TYPE="button" VALUE="Add" onClick="addValue('input1'),addUnit('input2'),addDescription('input3')"></TD>
</TR>
</FORM>
</BODY>
</HTML>