If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Frames and variables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-06-04, 12:44
computerforce computerforce is offline
Registered User
 
Join Date: Mar 2004
Posts: 84
Frames and variables

I have left and right frame at my webpage.

Left frame is main frame and there is menu to go to different pages - pages that appear at the right side frame.

at the right frame there are three select - menus (html) where user can choose one option, but at those right frames the menu is the same. Is there possibility to keep default value for the option for those right parts? How to have the value for use on any frame as default? Is there a posibility for that?
Reply With Quote
  #2 (permalink)  
Old 09-06-04, 14:29
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
You could do it through a session variable or cookie variable. Then each frame looks at the value in the session or cookie to set the default value.
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #3 (permalink)  
Old 09-06-04, 22:42
computerforce computerforce is offline
Registered User
 
Join Date: Mar 2004
Posts: 84
I am trying to use sessions - but there is number of pages at the right side.

Pages at the right side have their objects, properties, and also combo boxes - they have their. Is there any manual about the issue? References, variables and controls passing.
Reply With Quote
  #4 (permalink)  
Old 09-06-04, 23:45
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Session variable are global across all the pages.

http://www.4guysfromrolla.com/aspfaq...Q.asp?FAQID=30
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #5 (permalink)  
Old 09-07-04, 13:42
computerforce computerforce is offline
Registered User
 
Join Date: Mar 2004
Posts: 84
Let me explain this scenario:

I have one window.
Two frames.
At the left frame there is javascript menu.
At the right frame there can be 10 pages
At the right frame (every page) there are 2 combo boxes (the same for all ten pages). When visitor choses something from the right frame - using two combo boxes, down, below those two comboboxes he/she can get table of data as result of search.
Javascript menu allows users to choose one of those 10 pages at the right frame.
When one choses first page at the right window he/she would get the first page. After search (by using two comboboxes) he/she would get data - and his/her chosed data FROM COMBOS must go to SESSION variable. When he/she choses (at the left frame in javascript menu) another page which will appear at the right frame, he she would get the frame with two comboboxes, but in those two comboboxes he/she would have DEFAULTS from SESSION variable as data that was remembered from the first page. Also - the same for third, fourth and any other page.

Means - in SESSION variable user would have Default SELECT OPTION for the COMBO - LISTBOX.
Reply With Quote
  #6 (permalink)  
Old 09-07-04, 19:30
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Look Sep is perfectly right in what he is saying...

You create two sessions variables (example combo1default and combo2default).

In each of the 10 page in the right frame you check to see if combo1default is blank and if it is not blank you set that value as the default value for combo1. You do the same thing for combo2 using combo2default.

If the user changes the selected value and submits another search you reset combo1default and combo2default to the new values... so your code in each of the pages would look something like...
Code:
Dim submitCombo1, submitCombo2

' find the sumbitted values
submitCombo1 = Request.Form("Combo1")
submitCombo2 = Request.Form("Combo2")

' reset combo defaults to submitted values
if submitCombo1 <> "" then Session("Combo1Default") = submitCombo1
if submitCombo2 <> "" then Session("Combo2Default") = submitCombo2

' in loop for generating Combo box 1
Response.Write "<select name=Combo1>"
Do
  response.write "<option value=" & OptionValue
  if OptionValue = Session("Combo1Default") then response.write " selected"
  response.write ">" & Option & "</Option>"
Loop
Response.Write "</Select>"
Does that make sense?
Reply With Quote
  #7 (permalink)  
Old 09-07-04, 19:46
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Right.. sounds like a mix of JavaScript and ASP. Your combo box needs some JavaScript to submit a form to a page that will set the session variables. For hidden stuff like this, I use an IFrame with height and width set to 0. Then target that frame for your submission of the form. The page loaded in that frame will have some code that takes the values submitted, and stores them in the session.

The code below is free-form.. not tested.. more for you to just get an idea.. rok, does this seem adequate, or did I miss anything important?

Code:
<script language="JavaScript">
function setSessionVars(){
  document.setSessionVars.sessionVar1.value = document.comboBoxes.cb1.selectedIndex;
  document.setSessionVars.sessionVar2.value = document.comboBoxes.cb2.selectedIndex;
  docu,emt.setSessionVars.sumbit();
}
</script>

<form name="setSessionVars" target="hiddenFrame" method="post" action="setSessionVars.asp">
  <input type="hidden" name="sessionVar1" value="">
  <input type="hidden" name="sessionVar1" value="">
</form>

<form name="comboBoxes" method="post" action="someotherpage.asp">
  <select name="cb1" onChange="setSessionVars();">
    <option <%If Session("CBVar1") = 0 Then Response.Write "SELECTED" End If %>>Value 1</option>
    <option <%If Session("CBVar1") = 1 Then Response.Write "SELECTED" End If %>>Value 2</option>
    <option <%If Session("CBVar1") = 2 Then Response.Write "SELECTED" End If %>>Value 3</option>
  </select>

  <select name="cb2" onChange="setSessionVars();">
    <option <%If Session("CBVar2") = 0 Then Response.Write "SELECTED" End If %>>Value 1</option>
    <option <%If Session("CBVar2") = 1 Then Response.Write "SELECTED" End If %>>Value 2</option>
    <option <%If Session("CBVar2") = 2 Then Response.Write "SELECTED" End If %>>Value 3</option>
  </select>
</form>

<iframe name="hiddenFrame" height="0" width="0">
Then this could be the code for setSessionVars.asp
Code:
<%
  If Request.Form("cb1") <> "" Then
    Session("CBVar1") = Request.Form("cb1")
  End If

  If Request.Form("cb2") <> "" Then
    Session("CBVar2") = Request.Form("cb1")
  End If

%>
damn you rok.. beat me to it!
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #8 (permalink)  
Old 09-07-04, 20:53
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
You only really need to worry about the javascript if you want to submit with the onchange event..... personally I wouldn't worry about this until I had the base working.

nice code though Sepp.
Reply With Quote
  #9 (permalink)  
Old 09-07-04, 20:55
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
right, but he needs to set that session variable each time the combos change in case the user selects from the menu in the left frame...
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #10 (permalink)  
Old 09-07-04, 20:58
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Okie, I see what you are saying.... you could still run into problems... I suspect the the best way to do that particular bit would be to build javascript into the left frame to grab the values from the right frame and submit to the new page using those values.
Reply With Quote
  #11 (permalink)  
Old 09-07-04, 20:59
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
true.. do it entirely in JS.. very possible... wouldn't need a session variable that way
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On