G
gmail
Hi all--
I'm new to HTML and scripts and am having a problem with some code,
pasted in at the bottom. It uses javascript to get values from a form
in another frame, stores part of an SQL string in a cookie, then uses
vbscript to query a database. The page is reloaded by clicking a button
in another frame.
The problem I'm having is I have to reload the page twice (click the
button twice) before changed values are used. It seems like the
vbscript is executed before the javascript has finished, meaning the
request.cookies("WhereValue") is executed before the cookie value is set
by javascript, so the request pulls the old value. Is something like
this happening? What am I doing wrong here?
If anyone can point me in the right direction, I would appreciate it.
Thanks!
s
=== code ===
'rem -- this line reloads the page that will reflect changes (checkboxes
checked or unchecked.
'
<input type="button"
onclick="parent.frameSylvieResources.location.href='Sylvie_Resources.asp'"
value="Find these resources">
'rem -- And this is from the page being loaded
'
<html>
<script type="text/javascript">
function GetSelectedCats()
{
strSelected=""
strWhere=""
frmSelectedCats=parent.frameSylvieCategories.document.forms[0].SelCat
for (i=0;i<frmSelectedCats.length;++ i)
{
if (frmSelectedCats.checked)
{
strSelected=strSelected+frmSelectedCats.id + ", "
}
}
strSelected=strSelected.substr(0,strSelected.length-2)
if (strSelected.length > 0)
{
strWhere = "WHERE (((tblCategorys.fldCategoryID) In (" +
strSelected + "))) "
}
else
{
strWhere = "WHERE (((tblCategorys.fldCategoryID) In (0))) "
}
document.cookie="WhereValue='" + strWhere + "';"
}
</script>
<!--set up and draw the table of resources-->
<script type="text/javascript">
GetSelectedCats()
</script>
<%
strSQL=""
strWherevb=""
strWherevb=request.cookies("WhereValue")
strWherevb=mid(strWherevb,2,len(strWherevb)-2) & " "
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Sylvie"
set rs=Server.CreateObject("ADODB.recordset")
strSQL="SELECT DISTINCT tblResources.fldResourceID,
tblResources.fldResourceTitle, tblCategorys.fldCategoryID "
strSQL=strSQL + "FROM tblResources INNER JOIN (tblCategorys INNER JOIN "
strSQL=strSQL + "tblCategorysResourcesXref ON
tblCategorys.fldCategoryID = "
strSQL=strSQL + "tblCategorysResourcesXref.fldCategoryIDref) ON
tblResources.fldResourceID = "
strSQL=strSQL + "tblCategorysResourcesXref.fldResourceIDref "
strSQL=strSQL + strWherevb + "ORDER BY tblResources.fldResourceTitle;"
rs.Open strSQL, conn
strWherevb=""
%>
<body>
<h4>Resources--select a resource to see the details.</h4>
<table border="1" width=300px>
<%do until rs.EOF%>
<tr>
<td width=10px><input type="radio" name="ResourceMarker"> </td>
<td
width=235px><%Response.Write(rs.fields("fldResourceTitle").value)%></td>
<!--probably want the get it column to say the format-->
<td width=35px>Get it</td>
<%rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
</body>
</html>
I'm new to HTML and scripts and am having a problem with some code,
pasted in at the bottom. It uses javascript to get values from a form
in another frame, stores part of an SQL string in a cookie, then uses
vbscript to query a database. The page is reloaded by clicking a button
in another frame.
The problem I'm having is I have to reload the page twice (click the
button twice) before changed values are used. It seems like the
vbscript is executed before the javascript has finished, meaning the
request.cookies("WhereValue") is executed before the cookie value is set
by javascript, so the request pulls the old value. Is something like
this happening? What am I doing wrong here?
If anyone can point me in the right direction, I would appreciate it.
Thanks!
s
=== code ===
'rem -- this line reloads the page that will reflect changes (checkboxes
checked or unchecked.
'
<input type="button"
onclick="parent.frameSylvieResources.location.href='Sylvie_Resources.asp'"
value="Find these resources">
'rem -- And this is from the page being loaded
'
<html>
<script type="text/javascript">
function GetSelectedCats()
{
strSelected=""
strWhere=""
frmSelectedCats=parent.frameSylvieCategories.document.forms[0].SelCat
for (i=0;i<frmSelectedCats.length;++ i)
{
if (frmSelectedCats.checked)
{
strSelected=strSelected+frmSelectedCats.id + ", "
}
}
strSelected=strSelected.substr(0,strSelected.length-2)
if (strSelected.length > 0)
{
strWhere = "WHERE (((tblCategorys.fldCategoryID) In (" +
strSelected + "))) "
}
else
{
strWhere = "WHERE (((tblCategorys.fldCategoryID) In (0))) "
}
document.cookie="WhereValue='" + strWhere + "';"
}
</script>
<!--set up and draw the table of resources-->
<script type="text/javascript">
GetSelectedCats()
</script>
<%
strSQL=""
strWherevb=""
strWherevb=request.cookies("WhereValue")
strWherevb=mid(strWherevb,2,len(strWherevb)-2) & " "
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Sylvie"
set rs=Server.CreateObject("ADODB.recordset")
strSQL="SELECT DISTINCT tblResources.fldResourceID,
tblResources.fldResourceTitle, tblCategorys.fldCategoryID "
strSQL=strSQL + "FROM tblResources INNER JOIN (tblCategorys INNER JOIN "
strSQL=strSQL + "tblCategorysResourcesXref ON
tblCategorys.fldCategoryID = "
strSQL=strSQL + "tblCategorysResourcesXref.fldCategoryIDref) ON
tblResources.fldResourceID = "
strSQL=strSQL + "tblCategorysResourcesXref.fldResourceIDref "
strSQL=strSQL + strWherevb + "ORDER BY tblResources.fldResourceTitle;"
rs.Open strSQL, conn
strWherevb=""
%>
<body>
<h4>Resources--select a resource to see the details.</h4>
<table border="1" width=300px>
<%do until rs.EOF%>
<tr>
<td width=10px><input type="radio" name="ResourceMarker"> </td>
<td
width=235px><%Response.Write(rs.fields("fldResourceTitle").value)%></td>
<!--probably want the get it column to say the format-->
<td width=35px>Get it</td>
<%rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
</body>
</html>