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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!!! How to assign values to variables session in javascript?

Status
Not open for further replies.

DiegoErnesto

Programmer
Nov 28, 2001
41
EC
Hi.

I want assign the variable session from on_change function of INPUT form.

Following code:

<%@ Language=VBScript %>
<%
dim nAnio
dim nMes

nAnio = year(now())
nMes = month(now())

Session(&quot;Anio&quot;) = nAnio
Session(&quot;Mes&quot;) = nMes
%>
<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<LINK rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;Common/Style.css&quot;>
</HEAD>
<SCRIPT Language=&quot;JSCript&quot; >
nAnio = 0;
nMes = 0;

function clickmes()
{
var element = window.event.srcElement;

nMes = element.value;
// here I want assign value to variable session
// session(&quot;Mes&quot;)=nMes;
alert(nMes + &quot; &quot; + <%=nMes%>);
return 0;
}

function clickanio()
{

var element = window.event.srcElement

nAnio = element.value;
// here I want assign value to variable session
// session(&quot;Anio&quot;)=nAnio;
alert(nAnio & &quot; &quot; & <%=nAnio%>)
return 0;
}
</SCRIPT>

<BODY>
<TABLE>
<TR>
<TD>
<FORM name=frm1>
<INPUT size=5 name=m_Anio value=<%=nAnio%> onchange=clickanio()>
<SELECT style=&quot;WIDTH: 90px&quot; name=m_Mes onchange=clickmes()>
<OPTION value= 1 <%if (nMes= 1) then %>Selected<%end if%>>Enero</OPTION>
<OPTION value= 2 <%if (nMes= 2) then %>Selected<%end if%>>Febrero</OPTION>
<OPTION value= 3 <%if (nMes= 3) then %>Selected<%end if%>>Marzo</OPTION>
<OPTION value= 4 <%if (nMes= 4) then %>Selected<%end if%>>Abril</OPTION>
<OPTION value= 5 <%if (nMes= 5) then %>Selected<%end if%>>Mayo</OPTION>
<OPTION value= 6 <%if (nMes= 6) then %>Selected<%end if%>>Junio</OPTION>
<OPTION value= 7 <%if (nMes= 7) then %>Selected<%end if%>>Julio</OPTION>
<OPTION value= 8 <%if (nMes= 8) then %>Selected<%end if%>>Agosto</OPTION>
<OPTION value= 9 <%if (nMes= 9) then %>Selected<%end if%>>Septiembre</OPTION>
<OPTION value=10 <%if (nMes=10) then %>Selected<%end if%>>Octubre</OPTION>
<OPTION value=11 <%if (nMes=11) then %>Selected<%end if%>>Noviembre</OPTION>
<OPTION value=12 <%if (nMes=12) then %>Selected<%end if%>>Diciembre</OPTION>
</SELECT>


Thanks, for your help.
 
Client side Javascript and ASP cannot communicate directly. To create a session variable from client side Javascript, you have to submit a form with the variable value in it, then read it in and assign it to the session variable. You can set a cookie with the variable value in it in Javascript, and reference that instead, if you want.
 
Thank you.

Really, I had hopes that there was like make it.

Thank you again;

Diego Ernesto.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top