473,799 Members | 3,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session variables and arrays

All thanks in advance for reading my post. I am new to using js and
more accustomed to vbscript.

I had written code which created a shopping cart into an array using
vbscript and then transferred the information into a session
variable. However what I didn't know was that deleting/manipulating
information in an array using vbscript was not that easy.

In doing some reading and research it seemed that js was more flexible
in this area. My questions:

1) if I want to store cart items/details in an array and session
variable do I need to use only js (and can not switch back and forth
from vbscript and js)

2) if I have an array 6x12 and want to delete all the items
associated with say arrayItem[1, 0...12] what is the proper coding to
delete...is it splice?

3) any good articles about js, arrays, and multidimensiona l arrays
for a beginner?

sean

Jun 28 '07 #1
3 8462
On Jun 28, 10:50 am, sjsean <SJSean95...@gm ail.comwrote:
All thanks in advance for reading my post. I am new to using js and
more accustomed to vbscript.

I had written code which created a shopping cart into an array using
vbscript and then transferred the information into a session
variable. However what I didn't know was that deleting/manipulating
information in an array using vbscript was not that easy.

In doing some reading and research it seemed that js was more flexible
in this area. My questions:

1) if I want to store cart items/details in an array and session
variable do I need to use only js (and can not switch back and forth
from vbscript and js)
I'm not sure what you mean by session variable, let's just talk about
javascript Array objects. As far as I know, you can mix javascript
and VBscript in the same page if they are in separate script elements,
you are using IE and you follow appropriate syntax so ID knows what is
VBscript and what is javascript. It is a very bad idea, I don't
recommend it at all - stick with one or the other, preferably
javascript if you want it to run in any browser other than IE.

2) if I have an array 6x12 and want to delete all the items
associated with say arrayItem[1, 0...12] what is the proper coding to
delete...is it splice?
It depends what you mean by delete. If you have an array of 12 items
with index 0 to 11, you can assign any value you like to any element,
so one version of delete might be to simply set an element's value to
'null' or ''.

If you use the Array splice method (which can be used to remove a
range of elements, not just one), the element is removed and your
array now has indexes 0 to 10 and a length of 11. You can also use
shift and pop to remove the first and last elements respectively.

3) any good articles about js, arrays, and multidimensiona l arrays
for a beginner?
For a brief introduction to javascript arrays (don't use for..in with
arrays, though it's good to know it's there):

<URL: http://www.w3schools.com/js/js_obj_array.asp >

Then search the archives here. The ECMAScript specification isn't too
bad for arrays either, have a read and a bit of a play.

Some extras - initialise arrays using an initializer rather than a
constructor:

var arrayA = [];
var arrayB = ['foo', 'bar', 0, function(){...}];
The length property is automatically set as the largest used index
plus 1.

Sparse arrays are possible:

arrayA[10] = 'ipsum';
arrayA[100] = 'lorem';
alert(arrayA.le ngth); // shows 101
--
Rob

Jun 28 '07 #2
On Jun 28, 1:50 am, sjsean <SJSean95...@gm ail.comwrote:
All thanks in advance for reading my post. I am new to using js and
more accustomed to vbscript.

I had written code which created a shopping cart into an array using
vbscript and then transferred the information into a session
variable. However what I didn't know was that deleting/manipulating
information in an array using vbscript was not that easy.

In doing some reading and research it seemed that js was more flexible
in this area. My questions:

1) if I want to store cart items/details in an array and session
variable do I need to use only js (and can not switch back and forth
from vbscript and js)

2) if I have an array 6x12 and want to delete all the items
associated with say arrayItem[1, 0...12] what is the proper coding to
delete...is it splice?

3) any good articles about js, arrays, and multidimensiona l arrays
for a beginner?

sean

Hiya Sean
1)
My advice is store any and all sensitive data on the server, and
manipulate it there. Bear in mind that you will end up doing this
anyway, or someone could manipulate the javascript and if you dont
check it before using it, you could end up out of pocket.
Javascript should not be used as the core of any web app, but to
augment it for those with javascript enabled. This is really waht
sessions are for, the server side storage and manipulation of data so
that a user agent doesnt have to keep track of it all!

I'll leave 2 and 3 to someone else I think, but basically I would say
http://www.w3schools.com/js/js_obj_array.asp
something like that, or this: http://www.w3schools.com/jsref/jsref_obj_array.asp

Jun 28 '07 #3

"sjsean" <SJ*********@gm ail.comwrote in message
news:11******** **************@ e16g2000pri.goo glegroups.com.. .
All thanks in advance for reading my post. I am new to using js and
more accustomed to vbscript.

I had written code which created a shopping cart into an array using
vbscript and then transferred the information into a session
variable. However what I didn't know was that deleting/manipulating
information in an array using vbscript was not that easy.

In doing some reading and research it seemed that js was more flexible
in this area. My questions:

1) if I want to store cart items/details in an array and session
variable do I need to use only js (and can not switch back and forth
from vbscript and js)

2) if I have an array 6x12 and want to delete all the items
associated with say arrayItem[1, 0...12] what is the proper coding to
delete...is it splice?

3) any good articles about js, arrays, and multidimensiona l arrays
for a beginner?

sean
You're alluding to ASP programming, which is server-side. I believe the main
focus of this group is Client-Side Javascript.
Although you can use Javascript ( JScript) in lieu of VBScript for your ASP,
there's no need to switch from VBScript soley for handling a rectangular
array. If you're accustomed to the first element having an index of 1, and
accustomed to being able to ReDim your array, you may find the learning
curve switching to JScript a bit steeper than you may have anticipated. You
may ask yourself, for example, why do I want to delete elements of an array
in the first place.


Jun 29 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3474
by: Colin Steadman | last post by:
I have created a function to kill all session variables that aren't in a safe list. This is the function - Sub PurgeSessionVariables For Each Item In Session.Contents Select Case Trim(Item) Case "Authenticated" Case "CI_CODE" Case "organisation_description" Case "location_description"
4
12027
by: please-answer-here | last post by:
I want to store a bunch of textstrings (about 500) returned from a database query in a session array. I've googled all over the net, not to find any working method. Is there anybody who has the ultimative, definite working method as to how you transfer a "local" array to a session array and later transfer the session array to a "local" array. regards Henning
2
1710
by: adam | last post by:
Having spent nearly 2 years in win forms land the inevitable request came for me to "do some web pages". So being new to this bit of .net and having had a look around I can't see where the best way to store session data. 1) use the (string)Session approach Obviously bad for maintenance, readability etc. 2) have a typed MySession object with static properties for each value I want to store
4
1734
by: Andy Kasotia | last post by:
I have read couple of articles warning against the use of storing VB COM objects (Apartment Threading) in Session Variables due to the fact that these variables could go bad. My question is what's the workaround this? I have also read about making ASP Stateless...I'm guessing that means turning the session and application variables off and if you do that then how do you pass information for a particular user from one page to another?
1
2002
by: Larry Neylon | last post by:
Hi, I'm working on a VBScript application on IIS6 and I'm looking for some advice about the best way of replacing or improving session variable usage. The application is in a secure extranet environment. Currently the application has a search customers page with 10 search fields which list the results below the search fields. The requirement for this screen was that the user could return to this result page at any point from any page...
22
3249
by: roadrunner | last post by:
Hi, Our website has recently been experiencing some problems under load. We have pinpointed a particular function which slows dramatically when we have these problems. Normally it should execute in under a second but it rises to about one minute under duress. The code is fairly straight forward with no calls to databases or any other servers. The only dubious thing I can see is that it retrieves several arrays from the Application...
2
1767
by: Michaelk | last post by:
Can somebody tell me how many Session variables would be considered exessive, and when they start really affect the server speed. For example on 20-30 asp pages I need to use about 200-300 session variables and 5 arrays by 1000 elements 50 characters long each. Let say having 300 users using those pages at the same time. Server is not the fastest one, just CPU 2.40GHz. So question is as a user am I going to feel a difference in speed...
9
2820
by: cendrizzi | last post by:
Hi all, I've read some stuff on this but can't seem to come up with a solution that works right. I have a semi-mature (yet very large and robust) internal web application that currently only works with one window open at a time. Maybe I'm abusing the use of $_SESSION but I have data entry processes split up in several steps (which is required since depending on what was put before determines what pages will be shown after). To store...
8
3026
by: Eddie | last post by:
I am having difficulty in setting variables in a session, and then accessing those variables throughout the web pages that they click on. After having them set a user name and password, successfully authenticating against Active Directory, I send them from the login.php page to the index.php page. But when I get to the index.php page, the session ID is visible, but the session variables and values are not. Can you help me out? Also,...
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.