Forum Moderators: open
PD: The Listbox must show the selected value and the user should have the possibility to select another value in the Listbox.
<body bgcolor="#ffffea">
<form action="change.asp" method="post">
<input type="hidden" id="form_action" name="form_action" value="chg_save">
<input type="hidden" id="Product_id" name="Product_id" value="<%Response.write(Request("Product_id")) %>">
<div>
<table align=center cellspacing=1 cellpadding=0 width="100%" border=0>
<tr><td height=25 class="headback"><font size=2><b>LU_PRODUCT - SAVE CHANGES</b></font></td></tr>
<tr><td height=15 class="textback" valign=middle style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:13px">You can change the following records:
</td>
</tr>
</table>
</div><br><br>
<div>
<table border=0 width=100% align="center" height="200">
<tr><td class="text"><b>Product:</b></td></tr>
<tr><td class="text"><input type="text" name="Product" size="40" maxlength="50" value="<%Response.write objRS("Product") %>"></td></tr>
<tr><td class="text" ><b>Service:</b></td></tr>
<tr><td class="text">
<select id="Service" name="Service" style="width:180px;">
<%
Dim SQLquery, objRS, strConn
strConn = ".."
SQLquery="SELECT p.*, s.Service FROM LU_Product AS p LEFT OUTER JOIN LU_Service AS s on s.Service_ID=p.Service_ID WHERE Product_id=" & Request("Product_id")
Set objRS = Conn.Execute(SQLquery)
While not objRS.EOF
Response.Write("<option value=" & Service_ID)
'If Service_ID = objRS("Service_ID") Then Response.Write("SELECTED")
Response.Write(">")
Response.Write objRS("Service")
Response.Write ("</option>")
objRS.MoveNext
Wend
%>
</select>
</td></tr>
<tr><td class="text" colspan=2> <b>Report:</b></td></tr>
<tr><td colspan=2><input type="text" name="Report" value="<% Response.write objRS("Report") %>" size="40" maxlength="50"></td></tr>
</table>
...
Either BOF or EOF is True, or the current row was deleted. The request process needs a current row.
/_rootverzeichnis/change.asp, line 0
The list box shows me the corresponding value to the selected row, but the user can't select any other value in the Listbox, if he wants to update the Service value (Is it clear?).
The Report input shows me nothing. It doesn't show me the Report value corresponding to the selected row. I think the error is in the listbox...
<% if objRS("Service_ID")=0 then %>
<option value="0" selected>Old contracts</option>
<%else%>
<option value="0">Old contracts</option>
<%end if%>
<% if objRS("Service_ID")=1 then %>
<option value="1" selected>Application Services</option>
<%else%>
<option value="1">Application Services</option>
<%end if%>
...
and so on, it works, the value corresponding to the selected row on the table, is shown in the Listbox, and the User can select another value in the Listbox too. But the problem: I use hier one table and I fill the large Code with "If"s (example above) 29x. How can I do this with two tables?, I tried so:
For Each Product_id in objRS.Fields
if Service_ID= objRS("Service_ID") then
Response.Write "<OPTION VALUE = " & objRS("Service_ID") & "SELECTED>"
Response.Write objRS("Service") & "</Option>"
else
Response.Write "<OPTION VALUE = " & objRS("Dienstleistungs_ID") & ">"
Response.Write objRS("Dienstleistung") & "</Option>"
End If
Next
It shows me the correct outputs, but I can't select another value in the Listbox, I can see only one value. I work here with 2 Tables, what I explained in my first question.
I would be happy, if that finally worked! I have so much stress.
first:
<%Response.write(Request("Product_id")) %>
you should write as:
<%=Request("Product_id")%>
it's the same thing.
as for the loop:
<select name=serviceId>
<%
if not objRS.EOF and not objRS.BOF then
while not objRS.EOF
%>
<option value="<%=objRS("Service_ID")%>" <% if Service_Id = objRS("Service_ID") then Response.Write(" SELECTED") end if%>><%=objRS("Service")%>
<%
objRS.MoveNext
wend
end if
%>
</select>
I'm not sure what you need with the second table, but this should get you going.
Chip-
Either BOF or EOF is True, or the current row was deleted. The request process needs a current row.
I can't believe, this problem is difficult to solve, I've been searching for a topic like this in Internet, but I didn't find anything...
Table LU_Product
-----------------
Product_id
Service_ID
Product
Report
Table LU_Service
-----------------
Service_ID
Service