I have two comboboxes that populate data from a ms access database. I have a search box that looks for a chemical in a ms access database which then populates the comboboxes with the components of the chemical. The onchange event of the combo boxes then populates the textbox. THE PROBLEM: when I select one combobox data its textbox is populated but the other combobox and its textbox resets itself/ blanks out and vise-versa.
I am stuck on how to resolve this. I believe the whats happening is that when one combobox is activated the other is goes to End of File.
CONNECTION
Code:
<%@ Language=VBScript %>
<%Option explicit
Dim conn, connect
set conn=server.CreateObject ("adodb.connection")
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("ChemComp.mdb") & ";Persist Security Info=False"
conn.Open connect
%>
JAVASCRIPT
Code:
<html>
<head>
<title>Example combo box</title>
<script language="javascript">
<!--
function chemC_change(frmSelect) {
frmSelect.submit();
}
//-->
</script>
<script language="javascript">
<!--
function chemC_change2(frmSelect2) {
frmSelect2.submit();
}
//-->
</script>
MAIN FORM
Code:
</head>
<body>
<form name="form" method="POST" action="chemcomp123004-1form.asp">
<div align="center"><strong>Enter Chemical Name:</strong><br>
<input name="test" type="text" value="<%=Request.Form("test")%>">
<input type="submit" name="Submit" value="Submit">
</div>
</form>
<form name="frmSelect" method="POST" action="chemcomp123004-1form.asp">
<blockquote>
<p>Fiber In Media:<br>
<SELECT name=components LANGUAGE=javascript onchange="chemC_change(frmSelect)">
<%
Dim comp_name
Dim MaxTemp
' if course is not selected, add firt item telling them to select a first name
comp_name = Request.Form("components") & ""
if comp_name = "" then
Response.Write "<option value='Select a Chemical Name' SELECTED>Select a Chemical Name</option>"
end if
Do while not oRs.EOF
if comp_name = oRs("ComponentName") then 'if this is the selected one then display as selected
Response.Write "<option value= '" & oRs ("ComponentName") & "' SELECTED>"
Response.Write oRs("ComponentName") & "</Option>"
oRs.MoveNext
else
Response.Write "<option value= '" & oRs ("ComponentName") & "'>"
Response.Write oRs("ComponentName") & "</Option>"
oRs.MoveNext
end if
loop
%>
</SELECT>
<%
If rstry.EOF then
MaxTemp = ""
else
MaxTemp = rstry("MaxOprTemp")
end if
%>
<input name="textfield" type="text" value="<%=MaxTemp%>" size="10">
<input type="hidden" name="test" value="<%=Request.Form("test")%>">
</p>
</blockquote>
<%
oRs.Close
Set oRs = nothing
rstry.Close
Set rstry = nothing
%>
</form>
<form name="frmSelect2" method="POST" action="chemcomp123004-1form.asp">
<blockquote>
<p>Stack Gaskets:<br>
<SELECT name=componentsII LANGUAGE=javascript onchange="chemC_change2(frmSelect2)">
<%
Dim comp_name2, componentsII
Dim MaxTemp2
' if course is not selected, add firt item telling them to selec a first name
comp_name2 = Request.Form("componentsII") & ""
if comp_name2 = "" then
Response.Write "<option value='Select a Chemical Name' SELECTED>Select a Chemical Name</option>"
end if
Do while not oRs2.EOF
if comp_name2 = oRs2("ComponentName") then 'if this is the selected one then display as selected
Response.Write "<option value= '" & oRs2 ("ComponentName") & "' SELECTED>"
Response.Write oRs2("ComponentName") & "</Option>"
oRs2.MoveNext
else
Response.Write "<option value= '" & oRs2 ("ComponentName") & "'>"
Response.Write oRs2("ComponentName") & "</Option>"
oRs2.MoveNext
end if
loop
%>
</SELECT>
<%
if rstry2.EOF THEN
MaxTemp2 = ""
else
MaxTemp2 = rstry2("MaxOprTemp")
end if
%>
<input name="textfield" type="text" value="<%=MaxTemp2%>" size="10">
<input type="hidden" name="test" value="<%=Request.Form("test")%>">
<%
oRs2.Close
Set oRs2 = nothing
rstry2.Close
Set rstry2 = nothing
%>
</p>
</blockquote>
</form>
<p> </p>
</body>
</html>