|
|
We want to link two control boxes in asp using javascript, i.e.; when we select from first control box, based on the selection the second control box should be updated accordingly (based on an sql script).
But when we are selecting an 'option value' from the first control box we are losing focus on selected index after 'submit'ing the page. We have to submit page in order to update the second control box.
Any suggestions on how to resolve this issue.
Following is the code used:
<%@ language = "VBscript" %>
<%
option explicit
Response.Buffer = True
' On Error Resume Next
%>
<!--#include file="..\report-library\dtfmtval.asp" -->
<!--#include file="..\report-library\dtfmtval3.asp" -->
<%
dim Conn, Rs1,Rs2,Rs3,Day,day1,Mon,mon1,Year,year1,hours,mins,secs,mydate,mydate1, PlantAreas
mydate = Day & "-" & Mon & "-" & year &" "& hours & ":" & mins & ":" & secs
mydate1 = Day1 & "-" & Mon1 & "-" & year1 &" "& hours & ":" & mins & ":" & secs
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS1 = Server.CreateObject("ADODB.Recordset")
Set RS2 = Server.CreateObject("ADODB.Recordset")
Conn.ConnectionString = "DSN=rbv;UID=; password="
Conn.Open
Rs1.Open "SELECT select_description PlantArea FROM GetPlantAreas ORDER BY SELECT_DESCRIPTION ASC", Conn
Rs2.Open "select distinct substring(1 of name between '.') sample_point from AT_LIMSNumDef ", Conn
PlantAreas = Request.Form("PlantArea")
if PlantAreas <> "" then ' if the user made an entry
set rs2=conn.Execute("select distinct substring(1 of name between '.') sample_point from AT_LIMSNumDef where IP_PLANT_AREA = '"&PlantAreas&"' ")
end if
%>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Resources</title>
<script Language = "Javascript">
<!--
function ShowAll() {
location.href='LabVals.asp';
}
-->
</script>
<script language="JavaScript" src="../report-library/ts_picker.js">
</script>
<script language="JavaScript" src="../report-library/dt_chk.js">
</script>
<script language="JavaScript" src="../report-library/calendar1.js">
</script>
</head>
<body>
<p align="center"><u><b><font size="5">LABORATORY VALUES REPORT</font></b></u></p>
<table border="1" cellpadding="0" cellspacing="0">
<tr style=background=#4A3C8C;color=white>
<form name="tstest" method =post onSubmit="return CheckDate(document.tstest.stime.value,document.tstest.etime.value);">
<td><b>From</b></td>
<td>
<input type="Text" name="stime" value= "<% =(mydate1) %>"/>
<a href="javascript:cal1.popup();"><img src="../report-library/img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the Start Time"></a>
</td>
<td><b>To</b></td>
<td>
<input type="Text" name="etime" value= "<% =(mydate) %>"/>
<a href="javascript:cal2.popup();"><img src="../report-library/img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the End Time"></a>
</td>
<td><b>PlantArea</b></td>
<td>
<select name="PlantArea" id="PlantArea" onchange="document.tstest.submit()" >
<option value = "ALL" >ALL</option>
<% while not rs1.eof %>
<option value ="<% =rs1("PlantArea") %>" > <% =rs1("PlantArea") %> </option>
<% rs1.MoveNext
wend
%> </select>
</td>
<td><b>Sample_Point</b></td>
<td>
<select name="Sample_Point" id="Sample_Point" onchange="document.tstest.submit()">
<option value = "ALL" >ALL</option>
<% while not rs2.eof %>
<option value ="<% =rs2("Sample_Point") %>" > <% =rs2("Sample_Point") %> </option>
<%
rs2.MoveNext
wend
%> </select></td>
<td><input type="submit" name="Menu" value="Execute">
</td>
</tr>
</form>
<script language="JavaScript">
var cal1 = new calendar1(document.forms['tstest'].elements['stime']);
cal1.year_scroll = true;
cal1.time_comp = true;
var cal2 = new calendar1(document.forms['tstest'].elements['etime']);
cal2.year_scroll = true;
cal2.time_comp = true;
</script>
</body>
</html>
|
|
|
|
|
|
|
|