DefinityCorporation
IS-IT--Management
Hey guys, I have 2 drop downs from DB. "Company_ID" & "Location1" the first displays a list of our customer's company names and the second then shows a list of their employees. So I select "Microsoft" from box1 and then box2 is populated with "Bill Gates, Steve Balmer, Etc. Everything works BUT when I click the company name, and the page refreshes, the company name in first box disapears! So my question is: How do I put the company name back in the drop down during the OnChange=Submit??? Also, any comments on this code/method would be VERY helpfull because this is only my second week in ASP!
Info: Win2k server, IIS 5.0, SQL2k.
company_id = integer (1,2,3)
location1 = company name (microsoft, intel, xyz)
Heres the relevant part:
<FORM METHOD="POST" NAME="Form1" ACTION="newprinter.asp">
<SELECT NAME="Company" SIZE="1" ONCHANGE=Form1.submit()>
<option selected value="<% = Request.Form("location_1"
%>"><% = Request.Form("location_1"
%></option>
<%
' Get list of Companies to diplay
Dim rstCompany
Set rstCompany = SQLQuery(cnnDB, "SELECT DISTINCT company_id, location1 FROM tblusers WHERE company_id > 0 ORDER BY location1 ASC"
If not rstCompany.EOF Then
Do While Not rstCompany.EOF
%>
<option value="<% = rstCompany("company_id"
%>">
<% = rstCompany("location1"
%>
</option>
<%
rstCompany.MoveNext
Loop
End If
%> </select></td>
</tr>
</form>
</SELECT>
<FORM METHOD="POST" NAME="Form2" ACTION="newprinter.asp">
<input type="hidden" name="save" value="1">
<input type="hidden" name="etype" value="3">
<tr>
<td width="168" align="left" height="25">
<b><%=lang(cnnDB, "SelectUser"
%>:</b>
</td>
<td width="250" align="left" height="25">
<select name="uselectid">
<option value="0" selected><%=lang(cnnDB, "SelectUser"
%></option>
<%
' Get list of users to diplay
Dim rstUser
Set rstUser = SQLQuery(cnnDB, "SELECT * FROM tblUsers WHERE company_id = '" & Request.Form("Company"
& "'"
If not rstUser.EOF Then
Do While Not rstUser.EOF
%>
<option value="<% = rstUser("sid"
%>">
<% = rstUser("uid"
%> (<% = rstUser("fname"
%>)
</option>
<%
rstUser.MoveNext
Loop
End If
%>
</select>
Info: Win2k server, IIS 5.0, SQL2k.
company_id = integer (1,2,3)
location1 = company name (microsoft, intel, xyz)
Heres the relevant part:
<FORM METHOD="POST" NAME="Form1" ACTION="newprinter.asp">
<SELECT NAME="Company" SIZE="1" ONCHANGE=Form1.submit()>
<option selected value="<% = Request.Form("location_1"
<%
' Get list of Companies to diplay
Dim rstCompany
Set rstCompany = SQLQuery(cnnDB, "SELECT DISTINCT company_id, location1 FROM tblusers WHERE company_id > 0 ORDER BY location1 ASC"
If not rstCompany.EOF Then
Do While Not rstCompany.EOF
%>
<option value="<% = rstCompany("company_id"
<% = rstCompany("location1"
</option>
<%
rstCompany.MoveNext
Loop
End If
%> </select></td>
</tr>
</form>
</SELECT>
<FORM METHOD="POST" NAME="Form2" ACTION="newprinter.asp">
<input type="hidden" name="save" value="1">
<input type="hidden" name="etype" value="3">
<tr>
<td width="168" align="left" height="25">
<b><%=lang(cnnDB, "SelectUser"
</td>
<td width="250" align="left" height="25">
<select name="uselectid">
<option value="0" selected><%=lang(cnnDB, "SelectUser"
<%
' Get list of users to diplay
Dim rstUser
Set rstUser = SQLQuery(cnnDB, "SELECT * FROM tblUsers WHERE company_id = '" & Request.Form("Company"
If not rstUser.EOF Then
Do While Not rstUser.EOF
%>
<option value="<% = rstUser("sid"
<% = rstUser("uid"
</option>
<%
rstUser.MoveNext
Loop
End If
%>
</select>