[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

combobox keeping sessioned data

Posted on 2013-06-21
3
Medium Priority
?
256 Views
Last Modified: 2013-06-22
I have 2 different web pages both use excel workbooks as back ends. I pull one up and hit the drop down to select a category and hit submit it works fine. then I navigate to the next web page, code is identicle just use different excel workbooks with different named ranges as the data tables but when I click the drop down to select the category, it give me the choices from the 1st page and those choices do not exist on the 2nd page. I have tried using
<%
session.Contents.Remove("Category")
%>  

but theproblem is it seems that now no matter what i do it just retains the categories from which ever page i look at first. and from then on it will not change.

the code for page one:

<%@ Language=VBScript %>
<!--#include file="../includes/adovbs.inc"-->
<!--#include file="../includes/MakeComboBox.inc"-->
<%


'	mypaths = Request.ServerVariables ("appl_physical_path")
	vXlsFile = "/virtual/documents/powerfacts.xls"
	

	'MyConnString = "DRIVER=Microsoft Excel Driver (*.xls); DBQ=" & vXlsFile & ";DriverId=790;FIL=excel 8.0;MaxBufferSize=512;PageTimeout=5;"

	'Open Database Connection
	'Set Conn = Server.CreateObject("ADODB.Connection")
	'Conn.Open MyConnString
	
vXlsFile = Server.Mappath(vXlsFile)

		ExcelConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
		"Data Source=" & chr(34) & vXlsFile & chr(34) & ";" & _
		"Extended Properties=" & chr(34) & "Excel 8.0;"& chr(34)

		'Open Database Connection
		Set Conn = Server.CreateObject("ADODB.Connection")
		Conn.Open ExcelConnString

	
	
	Session("Category") = request.querystring("Category")
	Session("OpType") = request.querystring("OpType")	
	Session("SearchType") = request.querystring("SearchType")	
	Session("SearchWords") = request.querystring("SearchWords")	
%>
<html>

<head>
<!-- ////////////////////////////////////////////////////////////////////////////// -->
	<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=8" />
	<link rel="stylesheet" type="text/css" href="/styles/default.css" />
	<link rel="stylesheet" type="text/css" href="/common/styles/default.css" />
	<script src="/common/scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
	<script src="/common/scripts/menu.js" type="text/javascript"></script>
	<script src="/common/scripts/typeface-0.15.js" type="text/javascript"></script>
	<script src="/common/scripts/misterkot_regular.typeface.js" type="text/javascript"></script>
	<!-- ////////////////////////////////////////////////////////////////////////////// -->

		
	<title>Powerfacts</title>
	<style type="text/css">
	.auto-style1 {
		border-width: 0px;
	}
	</style>


</head>
<script LANGUAGE="vbscript">
<!--
	sub Myformsubmit(index)
		select case index
			case 1 'Submit by Category
			MyForm.OpType.value = "Submit"
			MyForm.SearchType.value = "Category"
			MyForm.SearchWords.value = ""
			MyForm.submit
			case 2 'Submit by Search word
			MyForm.OpType.value = "Submit"
			MyForm.SearchType.value = "Word"
			MyForm.Category.value = ""
			MyForm.submit

		end select
	end sub
-->
</script>
<body onload="SetMenu()">

<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td name="HeaderCell" id="HeaderCell"><a name="Top"></a><!--webbot bot="HTMLMarkup" ALT="&lt;h4&gt;The new  Header is in place ...&lt;/h4&gt;" TAG="XBOT" StartSpan -->
		<div id="dow-header"><iframe scrolling="no" width="100%" height="128" frameborder="0" marginheight="0" src="/common/temp/header.htm"></iframe></div>
	<!--webbot BOT="HTMLMarkup" endspan -->
</td>
  </tr>
  <tr>
    <td><div align="left"><table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <td width="81%">
         <!-- ////////////////////////////////////////////////////////////////////////////// -->
		<!--#include file="../includes/site_header_new.htm" TAG="BODY" -->
	<!-- ////////////////////////////////////////////////////////////////////////////// --></td>
        <td name="RightMarginCell" id="RightMarginCell" rowspan="2"><img height="1" hspace="60" src="ht/common/images/rightspacer.gif" width="78"><p><!--webbot bot="PurpleText" PREVIEW="do not modify." --></td>
      </tr>
      <tr>
        <td><table name="ContentTable" id="ContentTable" border="0" cellpadding="6" cellspacing="0" width="100%">
          <tr>
            <td name="MenuCell" id="MenuCell" valign="top" >
            <!--webbot bot="Include" U-include="../includes/menu.htm" TAG="BODY" --></td>            <td class="Content" name="ContentCell" id="ContentCell" valign="top" width="80%">
            <h1>Powerfacts</h1>
            <p>
<form method="get" name="MyForm" action="powerfacts.asp">
          <input type="hidden" name="OpType" value="<%=session("OpType")%>"><input type="hidden" name="SearchType" value="<%=session("SearchType")%>"><table class="TableNormal">
            <tr>
              <td Width="150" valign="top"><strong>Category</strong></td>
              <td Width="100" valign="top"><%			MakeComboBox "Category","SELECT DISTINCT tblPowerFacts.Category FROM tblPowerFacts ORDER BY tblPowerFacts.Category;",Session("Category"),22,150,2
%>
</td>
              <td width="150" align="center"><input type="button" Value="Submit" class="button" id="button1" name="button1" onclick="MyFormSubmit(1)"></td>
              <td width="250"></td>
            </tr>
            <tr>
              <td width="150" valign="top">or</td>
              <td width="100"></td>
              <td width="150"></td>
              <td width="250"></td>
            </tr>
            <tr>
              <td Width="150" valign="top"><strong>Search words</strong></td>
              <td Width="100" valign="top"><input size="30" align="left" type="text" id="SearchWords" name="SearchWords" value="<%=Session("SearchWords") %>"></td>
              <td width="150" align="center"><input type="button" Value="Submit" class="button" id="button1" name="button1" onclick="MyFormSubmit(2)"></td>
              <td width="250"></td>
            </tr>
          </table>
        </form>
        <hr noshade size="1">
        <p><%

if session("OpType")="Submit" then

	If session("SearchType") = "Category" then	
		sql = "SELECT tblPowerFacts.PowerFact FROM tblPowerFacts WHERE (((tblPowerFacts.Category)='" & session("Category") & "'));"
	end if
	
	If session("SearchType") = "Word" then
		Sql = "SELECT tblPowerFacts.PowerFact FROM tblPowerFacts WHERE (((tblPowerFacts.PowerFact) Like '%" & Session("SearchWords") & "%'));"
	end if

	set RS = server.createobject("adodb.recordset")
	
	RS.open sql,Conn,adOpenForwardOnly,adLockReadOnly 
	
	if rs.bof and rs.eof then
		response.write "<br>No Records Returned!"
	else	
		Rs.Movefirst
		'<TABLE border=1 cellPadding=3 cellSpacing=3 width="650" >
%> </p>
        <table>
<%	
		do while not Rs.EOF
	
%>
          <tr>
            <td></td>
          </tr>
          <tr>
            <td><%=RS.Fields("PowerFact").Value%>
</td>
          </tr>
<%
			rs.MoveNext 
		loop
%>
        </table>
<%
	end if
	rs.Close
	set rs = nothing
end if

Conn.Close
set conn = nothing



%>
          
            
            </td>
          </tr>
          <tr>
            <td name="FooterCell" id="FooterCell" valign="top"></td>
            <td name="Footer" id="Footer">
            <!--webbot bot="Include" U-include="../includes/footer_dexter.htm" TAG="BODY" -->
</td>
          </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td name="SpacerCell" id="SpacerCell"><img height="1" src="/common/images/topspacer.gif" width="640"></td>
      </tr>
    </table>
    </div></td>
  </tr>
</table>
</body>
</html>

Open in new window


the code for the 2nd page:

<%@ Language=VBScript %>
<!--#include file="../includes/adovbs.inc"-->
<!--#include file="../includes/MakeComboBox.inc"-->
<%

	vXlsFile = "/virtual/documents/LegacyLearnings.xls"


	'MyConnString = "DRIVER=Microsoft Excel Driver (*.xls); DBQ=" & vXlsFile & ";DriverId=790;FIL=excel 8.0;MaxBufferSize=512;PageTimeout=5;"

	'Open Database Connection
	'Set Conn = Server.CreateObject("ADODB.Connection")
	'Conn.Open MyConnString
	
vXlsFile = Server.Mappath(vXlsFile)

		ExcelConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
		"Data Source=" & chr(34) & vXlsFile & chr(34) & ";" & _
		"Extended Properties=" & chr(34) & "Excel 8.0;"& chr(34)

		'Open Database Connection
		Set Conn = Server.CreateObject("ADODB.Connection")
		Conn.Open ExcelConnString

	
	
	Session("Category") = request.querystring("Category")
	Session("OpType") = request.querystring("OpType")	
	Session("SearchType") = request.querystring("SearchType")	
	Session("SearchWords") = request.querystring("SearchWords")	
%>
<html>

<head>
<!-- ////////////////////////////////////////////////////////////////////////////// -->
	<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=8" />
	<link rel="stylesheet" type="text/css" href="/styles/default.css" />
	<link rel="stylesheet" type="text/css" href="/common/tdcc-temp/styles/default.css" />
	<script src="/common/scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
	<script src="/common/scripts/menu.js" type="text/javascript"></script>
	<script src="/common/scripts/typeface-0.15.js" type="text/javascript"></script>
	<script src="/common/scripts/misterkot_regular.typeface.js" type="text/javascript"></script>
	<!-- ////////////////////////////////////////////////////////////////////////////// -->

		
	<title>Legacy Learnings</title>
	<style type="text/css">
	.auto-style1 {
		border-width: 0px;
	}
	</style>


</head>
<script LANGUAGE="vbscript">
<!--
	sub Myformsubmit(index)
		select case index
			case 1 'Submit by Category
			MyForm.OpType.value = "Submit"
			MyForm.SearchType.value = "Category"
			MyForm.SearchWords.value = ""
			MyForm.submit
			case 2 'Submit by Search word
			MyForm.OpType.value = "Submit"
			MyForm.SearchType.value = "Word"
			MyForm.Category.value = ""
			MyForm.submit

		end select
	end sub
-->
</script>
<body onload="SetMenu()">

<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td name="HeaderCell" id="HeaderCell"><a name="Top"></a><!--webbot bot="HTMLMarkup" ALT="&lt;h4&gt;The new Header is in place ...&lt;/h4&gt;" TAG="XBOT" StartSpan -->
		<div id="dow-header"><iframe scrolling="no" width="100%" height="128" frameborder="0" marginheight="0" src="/common/temp/header.htm"></iframe></div>
	<!--webbot BOT="HTMLMarkup" endspan -->
</td>
  </tr>
  <tr>
    <td><div align="left"><table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <td width="81%">
         <!-- ////////////////////////////////////////////////////////////////////////////// -->
		<!--#include file="../includes/site_header_new.htm" TAG="BODY" -->
	<!-- ////////////////////////////////////////////////////////////////////////////// --></td>
        <td name="RightMarginCell" id="RightMarginCell" rowspan="2"><img height="1" hspace="60" src="common/images/rightspacer.gif" width="78"><p><!--webbot bot="PurpleText" PREVIEW="do not modify." --></td>
      </tr>
      <tr>
        <td><table name="ContentTable" id="ContentTable" border="0" cellpadding="6" cellspacing="0" width="100%">
          <tr>
            <td name="MenuCell" id="MenuCell" valign="top" >
            <!--webbot bot="Include" U-include="../includes/menu.htm" TAG="BODY" --></td>            <td class="Content" name="ContentCell" id="ContentCell" valign="top" width="80%">
            <h1>Legacy Learnings</h1>
            <p>
<form method="get" name="MyForm" action="LegLearnings.asp">
          <input type="hidden" name="OpType" value="<%=session("OpType")%>"><input type="hidden" name="SearchType" value="<%=session("SearchType")%>"><table class="TableNormal">
            <tr>
              <td Width="150" valign="top"><strong>Category</strong></td>
              <td Width="100" valign="top"><%			MakeComboBox "Category","SELECT DISTINCT tblLearnings.Category FROM tblLearnings ORDER BY tblLearnings.Category;",Session("Category"),22,150,2
%>
</td>
              <td width="150" align="center"><input type="button" Value="Submit" class="button" id="button1" name="button1" onclick="MyFormSubmit(1)"></td>
              <td width="250"></td>
            </tr>
            <tr>
              <td width="150" valign="top">or</td>
              <td width="100"></td>
              <td width="150"></td>
              <td width="250"></td>
            </tr>
            <tr>
              <td Width="150" valign="top"><strong>Search words</strong></td>
              <td Width="100" valign="top"><input size="30" align="left" type="text" id="SearchWords" name="SearchWords" value="<%=Session("SearchWords") %>"></td>
              <td width="150" align="center"><input type="button" Value="Submit" class="button" id="button1" name="button1" onclick="MyFormSubmit(2)"></td>
              <td width="250"></td>
            </tr>
          </table>
        </form>
        <hr noshade size="1">
        <p><%

if session("OpType")="Submit" then

	If session("SearchType") = "Category" then	
		sql = "SELECT tblLearnings.PowerFact FROM tblLearnings WHERE (((tblLearnings.Category)='" & session("Category") & "'));"
	end if
	
	If session("SearchType") = "Word" then
		Sql = "SELECT tblLearnings.PowerFact FROM tblLearnings WHERE (((tblLearnings.PowerFact) Like '%" & Session("SearchWords") & "%'));"
	end if

	set RS = server.createobject("adodb.recordset")
	
	RS.open sql,Conn,adOpenForwardOnly,adLockReadOnly 
	
	if rs.bof and rs.eof then
		response.write "<br>No Records Returned!"
	else	
		Rs.Movefirst
		'<TABLE border=1 cellPadding=3 cellSpacing=3 width="650" >
%> </p>
        <table>
<%	
		do while not Rs.EOF
	
%>
          <tr>
            <td></td>
          </tr>
          <tr>
            <td><%=RS.Fields("PowerFact").Value%>
</td>
          </tr>
<%
			rs.MoveNext 
		loop
%>
        </table>
<%
	end if
	rs.Close
	set rs = nothing
end if

Conn.Close
set conn = nothing
%>
           
            
            </td>
          </tr>
          <tr>
            <td name="FooterCell" id="FooterCell" valign="top"></td>
            <td name="Footer" id="Footer">
            <!--webbot bot="Include" U-include="../includes/footer_dexter.htm" TAG="BODY" -->
</td>
          </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td name="SpacerCell" id="SpacerCell"><img height="1" src="/common/images/topspacer.gif" width="640"></td>
      </tr>
    </table>
    </div></td>
  </tr>
</table>
</body>
</html>

Open in new window

0
Comment
Question by:jlcannon
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
G_H earned 2000 total points
ID: 39266386
OK, couple of things to look at:

Before Line 27 (where you SET Session(Category") ) check to see if Request.QueryString("Category") has a value. This may be re-setting a value you think you have cleared.

I the Sub "MyFormSubmit" write out (to screen)  the value in "index". This maybe set to 1 when you think it is a 2...

At line 129 you are checking for Session("SearchType") - have you cleared that as well as Session("Category")..?

HTH

GH
0
 

Author Comment

by:jlcannon
ID: 39267999
GH
I have cleared Session("SearchType")  and still no good. I am wondering is there a way to make sure the MakeComboBox is getting cleared and refreshed.

I found it! in the makecombobox.inc file there was a line that was telling it if session category data existed, use it to save time! So it was thank you, your help led me to this so Salute!
0
 

Author Closing Comment

by:jlcannon
ID: 39268002
Excellent direction!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question