Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2004
    Posts
    84

    Unanswered: 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?

  2. #2
    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.

  3. #3
    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.

  4. #4
    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.

  5. #5
    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.

  6. #6
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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?

  7. #7
    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.

  8. #8
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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.

  9. #9
    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.

  10. #10
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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.

  11. #11
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •