Click to See Complete Forum and Search --> : Duplicate Select Boxes


david2105
06-10-2003, 07:35 AM
Hi can anyone help me with this:

I have a function which is called when the checkbox at the end of the row is clicked. It will add a new row into a table and should populate the three cells with a drop down box, a text box and another check box.

<script type="text/javascript">
function insRow()
{
RowValue=document.forms.myform.valuebox.value
RowValue=(RowValue*1)+1

var x=myTable.insertRow()
var a=x.insertCell(0)
var b=x.insertCell(1)
var c=x.insertCell(2)
a.innerHTML="<p align='center'>" + WarehouseMaster.innerHTML + "</p>"
b.innerHTML="<p align='center'><input type='text' name='Req" + RowValue + "' size='5'></p>"
c.innerHTML="<p align='center'><input type='checkbox' name='checkbox" + RowValue + "' value='ON' onclick='insRow()'></p>"
NewRowCount.innerHTML="<input type='text' name='valuebox' size='5' value='" + RowValue + "'>"

var t=document.forms.myform
DisValue=RowValue*3
t[DisValue].disabled=true
}
</script>

The select drop down is populated with values from a database using ASP. I want to re-create this drop down with those values so I have used a <div> tag around the select statement (see below):

<div id="WarehouseMaster" style="visibility: visible">
<select name="Warehouse" size="1">
<%
DO WHILE NOT RSPart.EOF
%>
<option value="<%= RSPart("ITEM") %>"><%= RSPart("ITEM") %> - <%= RSPart("ITEM_DESC") %></option>
<%
RSPart.MoveNext
LOOP
%>
</select></div>

This all works correctly, when the check box is ticked a new row is displayed with the drop down and all the options populate correctly.

Now for the problem; I need to dynamically name the drop down using the RowValue variable as I have done for the text box and the check box. E.g. Name='Warehouse" + RowValue + "'. At present it takes the name of the select box in the <div> tag (Warehouse)

Does anyone know a way of calling the innerHTML of the select box below to get the necessary details from the select box but then being able to rename the select box as required?

Any help or ideas would be most helpful.

david2105
06-10-2003, 08:09 AM
Dave,

Thanks for the quick response. I only need to go Server-Side once to collect the data. After that it can be re-created Client-Side with the same options?