Forum Moderators: open
Im making a control panel where users can pick:
Table "Containers"
Field "name"
Field "value"
Table "Objects"
Field "name"
Field "value"
Users can specify custom names, values and number of rows for both tables. I have a page that lists the containers with the objects available to put into them. A text field displays the name field from the containers table and a select menu displays the name field from the objects table with the repeat behaviour applied to both. When a name from the objects select menu is chosen, its value is saved in the corresponding value field of the containers table.
Since the user can specify custom lables for the containers and objects, I must use a dynamic select menu. The problem I am having is getting the select menu to specify the current object in use for each container as the initially selected value of the select menu, which is equal to the corresponding value field of the containers table.
Does anyone know how to do this?
<form name="form1" method="post" action="">
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>Container</b></td>
<td><b>Object</b></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsContainers.EOF))
%>
<tr>
<td width="109"><input name="name" type="text" id="name" value="<%=(rsContainers.Fields.Item("name").Value)%>" size="20" maxlength="20">
</td>
<td width="144"><select name="name" id="name">
<%
While (NOT rsObjects.EOF)
%>
<option value="<%=(rsObjects.Fields.Item("value").Value)%>" <%If (InStr(1,(rsContainers.Fields.Item("value").Value),(rsObjects.Fields.Item("name").Value))>=1) Then Response.Write("SELECTED")%>><%=(rsObjects.Fields.Item("name").Value)%></option>
<%
rsObjects.MoveNext()
Wend
If (rsObjects.CursorType > 0) Then
rsObjects.MoveFirst
Else
rsObjects.Requery
End If
%>
</select> </td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsContainers.MoveNext()
Wend
%>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</form>