Is it possible to assign a form value to a Session variable in Javascript 
Author Message
 Is it possible to assign a form value to a Session variable in Javascript

Hi,

I have a form with fields. I am using javascript for when a "change" event
occurs on one of the text fields. What I need to do, is in the text onChange
event, is to assign my server "Session(BUILDING)" variable to equal the new
value in the text field. For example, something like:

--- snip ---
<INPUT  NAME="BUILDING"  TYPE="TEXT"  onChange="blah(BUILDING.value)"; >
On the change event I call a javascript function passing in the new value in
the textbox... This works alrite...
--------

now in my javascript function I need to set the Session(BUILDING) variable
to equal the new value in the text box...
something like this.... (although it doesnt work because I get a syntax
error)

<SCRIPT LANGUAGE="Javascript">
function blah(new_value_in_textbox)
{
    <% Session(BUILDING) %>  = new_value_in_textbox

Quote:
}

</SCRIPT>

I am really stumped on how to do this guys... If anybody has any ideas or
feedback for me, I'd much appreciate it.

Nick



Fri, 26 Sep 2003 10:15:10 GMT  
 Is it possible to assign a form value to a Session variable in Javascript
Client side code can't interact directly with server side code or server side objects.  One
generally submits a form to another .asp page (or to a page designed to submit to itself).

You need to study up on the rather fundamental difference between client side code and the browser
document object model (DOM) and server side code and ASP object model...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> Hi,

> I have a form with fields. I am using javascript for when a "change" event
> occurs on one of the text fields. What I need to do, is in the text onChange
> event, is to assign my server "Session(BUILDING)" variable to equal the new
> value in the text field. For example, something like:

> --- snip ---
> <INPUT  NAME="BUILDING"  TYPE="TEXT"  onChange="blah(BUILDING.value)"; >
> On the change event I call a javascript function passing in the new value in
> the textbox... This works alrite...
> --------

> now in my javascript function I need to set the Session(BUILDING) variable
> to equal the new value in the text box...
> something like this.... (although it doesnt work because I get a syntax
> error)

> <SCRIPT LANGUAGE="Javascript">
> function blah(new_value_in_textbox)
> {
>     <% Session(BUILDING) %>  = new_value_in_textbox
> }
> </SCRIPT>

> I am really stumped on how to do this guys... If anybody has any ideas or
> feedback for me, I'd much appreciate it.

> Nick



Fri, 26 Sep 2003 10:24:23 GMT  
 Is it possible to assign a form value to a Session variable in Javascript
YOu have to submit the form and in asp do
Session("Building") = Request.Form("building")

YOU HAVE TO SUBMIT IT!!!
The reason for this is that Session variables are actually stored in memory on
the server, not the browser.

Quote:

>Hi,

>I have a form with fields. I am using javascript for when a "change" event
>occurs on one of the text fields. What I need to do, is in the text onChange
>event, is to assign my server "Session(BUILDING)" variable to equal the new
>value in the text field. For example, something like:

>--- snip ---
><INPUT  NAME="BUILDING"  TYPE="TEXT"  onChange="blah(BUILDING.value)"; >
>On the change event I call a javascript function passing in the new value in
>the textbox... This works alrite...
>--------

>now in my javascript function I need to set the Session(BUILDING) variable
>to equal the new value in the text box...
>something like this.... (although it doesnt work because I get a syntax
>error)

><SCRIPT LANGUAGE="Javascript">
>function blah(new_value_in_textbox)
>{
>    <% Session(BUILDING) %>  = new_value_in_textbox
>}
></SCRIPT>

>I am really stumped on how to do this guys... If anybody has any ideas or
>feedback for me, I'd much appreciate it.

>Nick



Sat, 27 Sep 2003 01:35:42 GMT  
 Is it possible to assign a form value to a Session variable in Javascript
You need to have double quotes around your session variable
Example:
<% Session("BUILDING") %> = new_value_in_textbox
Quote:

> Hi,

> I have a form with fields. I am using javascript for when a "change" event
> occurs on one of the text fields. What I need to do, is in the text onChange
> event, is to assign my server "Session(BUILDING)" variable to equal the new
> value in the text field. For example, something like:

> --- snip ---
> <INPUT  NAME="BUILDING"  TYPE="TEXT"  onChange="blah(BUILDING.value)"; >
> On the change event I call a javascript function passing in the new value in
> the textbox... This works alrite...
> --------

> now in my javascript function I need to set the Session(BUILDING) variable
> to equal the new value in the text box...
> something like this.... (although it doesnt work because I get a syntax
> error)

> <SCRIPT LANGUAGE="Javascript">
> function blah(new_value_in_textbox)
> {
>     <% Session(BUILDING) %>  = new_value_in_textbox
> }
> </SCRIPT>

> I am really stumped on how to do this guys... If anybody has any ideas or
> feedback for me, I'd much appreciate it.

> Nick



Mon, 29 Sep 2003 10:05:42 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Passing a ASP Session Variable Value into a JavaScript function

2. assign value to variable in form module

3. Assigning the value to the value of a variable

4. Assign Session variable to textbox

5. Problem in assigning value to a variable

6. How to dynamically assign the value to variable...

7. Assigning values to Application scope variables from a recordset fails

8. cant assign returned function value to form object

9. Class Objects stored into session variables, not possible?

10. Possible to erase (de-allokate) session variables dynamically ???

11. Stuffing a Javascript Value into a VBScript Variable

12. Assign a value to a variable using Select

 

 
Powered by phpBB® Forum Software