Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update asp session with javascript values

Status
Not open for further replies.

antonyx6666

Programmer
Sep 9, 2010
38
0
0
GB
Hi, I have tried my best to get this working but I cannot go any further. I have working code on my website but am having difficulty incorporating a new function into the code.


There are 3 files in this project:

global.inc
OneForm.asp
OneForm.js.inc


I have a set of values in global.inc


Code:
Session("ListAttributes")	= [

	    ["Standard Saloon",     ["01. Saloon [SAL]"]],
            ["Executive Saloon",     ["07. Executive Saloon [EXEC-SAL]"]],
            ["Estate Vehicle",     ["02. Estate [EST]"]],
            ["People Carrier",     ["03. 5 Seater [5ST]"]],
            ["8 Seater Vehicle",     ["06. 8 Seater [8ST]"]]		
						
				];


At the top of my form OneForm.asp there is a function that takes the values from global.inc and places them in a session called VehAttr


Code:
var vehAttr  = new Array();

if (Session("ListAttributes"))
{
    var la = Session("ListAttributes");

    for (i = 0; i < la.length; i++)
    {
        vehAttr[i] = la[i][0];

        for (j = 0; j < la[i][1].length; j++)
        {
            Session("InvisibleDefaultVA")[la[i][1][j]] = false;
        }
    }
}

Session("VehAttr") = vehAttr;


They are also used in a drop down menu.


Code:
<%
      if (vehAttr.length > 0)
      {
%>

<select id="DDvehAttr" class="FormField" onchange="DDvehAttrChanged(this)" >
              <option value="-2">Please Select . . .</option>
<%
              for (i=0; i < vehAttr.length; i++)
              {%>
              <option value="<% = i %>"><% = vehAttr[i] %></option>
              <%}
%>
            </select>

<%
      }
%>


This all works fine.

There is another function in OneForm.js.inc that repopulates my drop down.


Code:
function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i][0];
optn.value = i-1;
dd2.options.add(optn);
}

}


This function uses the following values which are also held in OneForm.js.inc:


Code:
var AS_Airport =
    {
    group :
        "Heathrow Airport",

    premise:
        "Flight Number (eg VS401 Dubai)",

    shortcuts :
        [           

        ["HEATHROW TERMINAL 1", "Heathrow Airport - Terminal 1"],
        ["HEATHROW TERMINAL 3", "Heathrow Airport - Terminal 3"],
        ["HEATHROW TERMINAL 4", "Heathrow Airport - Terminal 4"],
        ["HEATHROW TERMINAL 5", "Heathrow Airport - Terminal 5"]
    
        ], 
    dd2options : 
        [
            
	    ["Please Select . . .",     [" "]],
            ["Standard Saloon",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
            ["Executive Saloon",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
            ["Estate Vehicle",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
            ["People Carrier",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
            ["8 Seater Vehicle",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]
     
    
            ]
     
    };


    var AddressShortcuts = [AS_Airport];



This all works fine. When the function runs it repopulates the drop down with no errors.

However, I need these new values (in addition to repopulating the drop down) to update the vehAttr session. I do not know how to update the session with these new values.

I presume this involves combining the 2 functions below and then refreshing the form.


Code:
function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i][0];
optn.value = i-1;
dd2.options.add(optn);
}

}

var vehAttr  = new Array();

if (Session("ListAttributes"))
{
    var la = Session("ListAttributes");

    for (i = 0; i < la.length; i++)
    {
        vehAttr[i] = la[i][0];

        for (j = 0; j < la[i][1].length; j++)
        {
            Session("InvisibleDefaultVA")[la[i][1][j]] = false;
        }
    }
}

Session("VehAttr") = vehAttr;


I cannot get my head round this. Can someone please assist me.
 
>Session("VehAttr") = vehAttr;
Session() is on the server. vehAttr is on the user agent's memory space. What do you say?

One day, people may write their framework, saying
[tt]Session("VehAttr") $=$ vehAttr; //fictitious syntax[/tt]
or something meaning a built-in xmlhttp request is sent to the server to do the job: not yet. You have to write it yourself. Hope that help you can get your head round this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top