Solved

Set session variable syntax

Posted on 2008-06-24
15
415 Views
Last Modified: 2010-04-21
Hi,

I have a page with 4 recordsets, each one returns one digit 0 - 9, so results could be:

recordset # 1 : 4
recordset # 2 : 5
recordset # 3: 9
recordset # 4: 4

I am setting a session variable to be equal to concatenating those numbers, something like: 4594

The code i have right now actually adds and gives me : 22 as result, how can i teak it to give me the 4594 result ?

<%
Session("codeid") =(SecurityCode1.Fields.Item("codenum").Value)+(Securitycode2.Fields.Item("codenum").Value)+(Secritycode3.Fields.Item("codenum").Value)+(Securitycode4.Fields.Item("codenum").Value);
%>

Thanks.
0
Comment
Question by:amucinobluedot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 4
15 Comments
 
LVL 22

Expert Comment

by:neeraj523
ID: 21854820
Here you go

<%
Session("codeid") = SecurityCode1.Fields.Item("codenum").Value & Securitycode2.Fields.Item("codenum").Value & Secritycode3.Fields.Item("codenum").Value & Securitycode4.Fields.Item("codenum").Value
%>
0
 
LVL 15

Expert Comment

by:dosth
ID: 21854824
<%
Session("codeid") =CStr(SecurityCode1.Fields.Item("codenum").Value)+CStr(Securitycode2.Fields.Item("codenum").Value)+CStr(Secritycode3.Fields.Item("codenum").Value)+CStr(Securitycode4.Fields.Item("codenum").Value);
%>
0
 
LVL 22

Expert Comment

by:neeraj523
ID: 21854832
or simplify it more

<%
Session("codeid") = SecurityCode1("codenum") & Securitycode2("codenum") & Secritycode3("codenum") & Securitycode4("codenum")
%>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:amucinobluedot
ID: 21854877
First and third solution adds to '0', second one gives me an error message.
0
 

Author Comment

by:amucinobluedot
ID: 21854902
BTW 'codenum' is an INT datatype, in case that has anything to do with this.
0
 
LVL 22

Expert Comment

by:neeraj523
ID: 21854913
what you mean to "adds to '0'"

can you tell me the output of this ??
<%
Response.Write (SecurityCode1("codenum") & Securitycode2("codenum") & Secritycode3("codenum") & Securitycode4("codenum"))

Session("codeid") = SecurityCode1("codenum") & Securitycode2("codenum") & Secritycode3("codenum") & Securitycode4("codenum")
%>

0
 
LVL 15

Expert Comment

by:dosth
ID: 21854921
can you tell me the error message

when you add it add as no, so we just need to convert to CStr()

it might be your semi colon or some thing
0
 
LVL 15

Expert Comment

by:dosth
ID: 21854931
<%
Dim SCode
SCode = CStr(SecurityCode1("codenum")) + CStr(SecurityCode2("codenum")) + CStr(SecurityCode3("codenum")) + CStr(SecurityCode4("codenum"))
Session("codeid") =SCode
%>

Yes, it is your semicolon at the end, we just copied that. please try replacing with this
0
 

Author Comment

by:amucinobluedot
ID: 21854980
neeraj523: out put for both is '0'

dosth: the code gives me this error:

Error Type:
Microsoft JScript compilation (0x800A03EC)
Expected ';'
/BlueDot/questionnaire/questionnairemainunsolicited.asp, line 654, column 4
Dim SCode
---^

Remember I am using ASP/Javascript
0
 
LVL 15

Expert Comment

by:dosth
ID: 21855075
then you need to use

<%
var SCode;
SCode = CStr(SecurityCode1("codenum")) + CStr(SecurityCode2("codenum")) + CStr(SecurityCode3("codenum")) + CStr(SecurityCode4("codenum"));
Session("codeid") =SCode;
%>
0
 
LVL 15

Expert Comment

by:dosth
ID: 21855115
ohhhhhhhh
there is not CStr in JScript " :)

let me find the alternate
0
 
LVL 15

Accepted Solution

by:
dosth earned 500 total points
ID: 21855279
<%
var c1,c2,c3,c4;

c1 = SecurityCode1("codenum")+'';
c2 = SecurityCode2("codenum")+'';
c3 = SecurityCode3("codenum")+'';
c4 = SecurityCode4("codenum")+'';

Session("codeid") = c1 + c2 + c3 + c4;

%>

or

<%
var c1,c2,c3,c4;

c1 = SecurityCode1("codenum");
c2 = SecurityCode2("codenum");
c3 = SecurityCode3("codenum");
c4 = SecurityCode4("codenum");

Session("codeid") = c1.toString() + c2.toString() + c3.toString() + c4.toString();

%>


0
 

Author Closing Comment

by:amucinobluedot
ID: 31470105
Thanks !
0
 
LVL 22

Expert Comment

by:neeraj523
ID: 21855333
hmm so u r using javascript in asp page..

try this..

<%
Session("codeid") =(SecurityCode1.Fields.Item("codenum").Value) + "" + (Securitycode2.Fields.Item("codenum").Value) + "" + (Secritycode3.Fields.Item("codenum").Value) + "" + (Securitycode4.Fields.Item("codenum").Value);
%>
0
 
LVL 15

Expert Comment

by:dosth
ID: 21855661
thanks for the points
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Ajax on ASP 2 68
Help with Classic ASP - Parameterizing Query 16 67
Multiple of Image Swaps 5 42
My tooltip is not displaying correct 11 19
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question