ReDim And Preserve For An ASP Array

I am implementing a site where an admin user can log purchases of items into a DB.
Obviouslt, one purchase can consist of many items. I am therefore trying to implement a 'Cart' idea wherby the user adds the items to be purchased to the cart and then completes the purchase once all items have been added to the cart.

i aM IMPLEMENTING THE CART FUNCTIONALITY VIA AN asp ARRAY. nOW I CAN Do THIS NO PROBLEM, APART FROM THE FACT THAT, i declare an array of size 10, with 5 attributes to each element. i.e.

Dim purchaseCart(10,4)

The problem is, i want to be able to ensure that if the user decides to purchase more then 10 items, that the array can be ReDimensioned to suit i.e. increase size by one every time another element is added, after it has reached its maximum size!! Code:

View Replies


ADVERTISEMENT

Redim Preserve

I'm trying to build an array with the ID's of the users I have in a Mysql table called tbl_user.
Here is what I coded :

dim listeId(1)
i = 0
Set rs=Conn.Execute("SELECT ID from tbl_user ORDER BY Id;")
Do While Not rs.EOF
if i = 0 then
listeId(i)= rs("ID")
else
REDIM PRESERVE listeId(i+1)
listeId(i)= rs("ID")
end if
i = i + 1
rs.MoveNext
Loop
rs.close

But I get this error: (0x800A000A)
which is something like "fixed or temporary locked array"

View Replies View Related

Redim Preserve MyArray(i)

Is it correct to think that after reducing the populated array's size from say, 10 to 5 with redim preserve myArray(i) an attempt to access an element above the fifth does not cause a compillation error "array out of script", but returns whatever heppened to
be written in that memory address (in particular it might return the correct values of those elements before re-dimentioning)?This seems to be the case in my code, yet I wanted to make sure that this isnot the result of some other side effect.

View Replies View Related

REDIM Preserve "Out Of Range"

REDIM Preserve reports an "out of range".

I first create an array, store it into a session var then, in other page, I load restore the session var into a local array but, after this, I can't REDIM Preserve.

View Replies View Related

ReDim Array

How an earth does this reDim of an array work ? I am looping through 1 array using a for loop and rediming an array within there. Code:

View Replies View Related

Redim Array In For Each Loop

I'm trying to build a piece of code that loops through the Request.Form collection, takes the "name" part of the name/value pair of each Item in the Request.Form collection, splits them into an array based on a common Form Field naming convention, and outputs the result (the full code will do much more - I'm just trying to build this in "baby steps").
Ex:

If my Form field names are:

t_FirstName
t_LastName
i_StateOfResidence

I wrote this code to loop through these, split them based on the underscore character ("_"), and output the results: Code:

View Replies View Related

How Can I "ReDim" A Two-dimensional Array?

I guess one should declare the array using empty brackets.

Dim MyArray()

Later I set MyArray to:

Redim MyArray(2,3)

The problem comes now. How should I use Redim again? I have heard that only one of the two dimensions can be enlarged or decreased. Is that correct? If so, which dimension would be ok to set to 5 in MyArray. Is ReDim MyArray (2,5) correct or should it be (5,2)?

View Replies View Related

Preserve Zeros

How can I read back info from a database into an input field (in case it's to be edited) that will preserve the zeros to the right of the decimal?The zeros are being preserved in the access database when I have a look at it there. I have the field defined as type "Currency" to two decimal places.

I want to preserve those zeros to the right of the decimal point when I read the record into an input tag on a web page.I am trying to use "FormatCurrency(request.form(exp, 2))" and "FormatNumber(request.form(exp, 2))" but it doesn't help.

View Replies View Related

Preserve Line Breaks

I've got the following code which should write the contents of a textarea to a '.txt' file:

Code:

set objFileSystem = server.createobject("Scripting.FileSystemObject")
set objFilePlainText = objFileSystem.CreateTextFile(server.mappath("templates/my-text-file.txt"),true)

objFilePlainText.write(strTemplatePlainText)

If I response.write this data before inserting to the txt file, it preserves the line breaks, but when it writes to the txt file it seems to lose all of the line breaks.
Does anyone know how to get this to preserve the formatting of the text being inserted?

View Replies View Related

Preserve Input Fields

I have a .asp form page that submits to another .asp page that uses cdonts to send me an email and does a response.redirect back to the form page. I need to preserve (keep) a couple of text box values and a couple of dropdown box values.

At this point I have global.asa variables for the fields in question and they are all set to null. I can't figure out how to put the contents back in the fields, when it returns from the cdonts page. I assume that I must save all the field values in the session variables just prior to the submit to the cdonts page.

show me how to accomplich this for one text field called name and one dropdown box called PUDeliv?

View Replies View Related

Rebuilding Of An Array From An Existing Array

I dump the entire recordset into an array:

If not rs.EOF Then
aEmp = rs.GetRows()

Contents of the array are in this order:

EmpID,EmpName,Indent,Sub_ID,Lft,Rgt,MgrID, LastName

This query sort on the basis of Lft and Rgt columns.

The name of the array is: aEmp.

My question here is how can I get only the LastName from the aEmp array into another array so that I can sort the names alphabetically and then display the employees in the alphabetical order.

Or is there is another way I could this by using the same array while keeping the lft and rgt sort of the query? If I sort based at the SQL query level, I can see the names sorted by the lft, rgt and lastname, but since the lastname is at the end of the sort list - it does not appear alphabetically.

View Replies View Related

Array Integers Vs Array Variables

In working with arrays, I have found that I am unable to dimension and array
with a variable that has an integer value but I can redimension one this
way. I haven't see any information that tells me if this is a requirement,
although it appears to be because I get an error if I try it.

Ex.

Dim b
b = 10
Dim a(b) ' this errors out but
Dim a() ' this
Redim a(b) ' works

Code:

View Replies View Related

Create A New Array From An Array

I want to create a new array called arrNames2 and copy contents of arrNames to arrNames2.

I then want to loop through my db and add more names (while going through the loop) to arrNames2. What is the best way to do this? Do I have to keep redim the array wehn I add more names?

View Replies View Related

Array In Sql

i want to excute given logic

select * from Product_Table where Product_Code in

ARRAY

i.e i want to select Product_Code from VB array and not from a query
is it possible.

View Replies View Related

Array

I know I can do this programatically using a loop but I thought there might be
some easier or more effective way.

I am trying to invert an array.

i.e.

array1 = 1,2,3,4,5

but I want to get

array2 = 5,4,3,2,1

Is there something like array2 = invert(array1)?

View Replies View Related

Array

I have to following code:Code:

dim arrRes(9),getal,som
arrRes=Array(4,4,4,4,4,5,5,5,5,5)
for getal=0 to 9
som=som+arrRes(getal)
next
response.write("Het klasgemiddelde is " &som/10)

I get a type not match error on the second line

View Replies View Related

ASP Array?

I have a page in my admin system where the user can edit products they
have added. The problem I am having is with Related Products. These are
all listed in a multiple list. What I need to do is have those selected
when the product was added, already be highlighted in the multiple list
on the product edit page. Here is my post from another forum.

Code:

View Replies View Related

Array

For some reason, when I try to run the following array, I'm getting an
error:

dim cat(0)

cat(0)="0407"
cat(1)="0102"

'I will be adding more to this array, but just trying with two for
starts.

for counter = 0 to 1

itno=cat(counter)

'I get an error when it runs through this function

Function rightvar(theVar,lengthNeeded)
Dim sResult
sResult=theVar
if Len(theVar)< lengthNeeded then sResult= String(lengthNeeded -
Len(theVar)," ")& theVar
rightvar=sResult
End Function

Can someone help me understand why?

View Replies View Related

Array

The problem is that in my 5 years of programming in various languages i have never really understood arrays (DUMB @$${lol})
What i want to do is offer an advanced search of a database table on my website. I currently offer the functionality so that the whole of the database can be viewed within the web page so that it doesn't need to be downloaded/need access to view it.
What i need to do is run a script that takes all of the column headings that i have and put them into an array. Then with the array i need to output each element into a drop down box.

View Replies View Related

Asp Array

Ok what I have is a little script which runs through my stock compares how many of one item we have compared to what we need and displays the out come.

What id like to do is make an array with the item name so lets say If how many is needed is greater then 0 then add the name of that consumable to an array and move on until the end.

Then I want to use the arry to display each consumable on an order form. Anyone have any idea how to do this in ASP or can give me any advice on a better way to do it?

View Replies View Related

Array

I am doing the following:
Code:

dim n
n=4'ubound(arrsequences)
response.write "n:" & n
dim arrproductNames(n)
dim arrproductSeq(n)

and getting the following error:
Microsoft VBScript compilation error '800a0402'
Expected integer constant
process.asp, line 33
dim arrproductNames(n)

View Replies View Related

Add Something To An Array

How can I add something to an array, e.g
[VBS]
Dim MyArray

MyArray = Array("Item 1", "Item 2", "Item 3")

'Do some code here

'I now want to add another item to my array, how?
[/VBS]

View Replies View Related

An Array

Is there a way of determining whether or not a value or values are present in an array.
Is there something nice and easy as with php's

if(in_array($SomeValue,$myArray)){
echo "The value is here";
}
else{
echo "The value is not here";

View Replies View Related

ASP Array

how to store request multiple value(Select box) in an array.

View Replies View Related

2D Array

im trying to write a script that will allow me to take names and addresses
from a coma delimetered text file and insert them into a db.

ive managed to come up with this script which deals with works well if i
only have names in the text file. ie:

bob smith, peter smith, brian smith

but now i want to do something simular with a text file formatted like so

bob smith, bob smiths address, peter smith, peter smiths address,

i think i have to use a 2 demensional array but really have no idea how to
go about it. any help appreciated. here is what i have so far. Code:

View Replies View Related

Array

I have a form that has fields named Title1, Title2, and so on to title 12

I want to set up an array that goes through all the input feild values that I already put into variables such as Title1, Title2...so on. It then replaces ' with '' so the apostrophe can be entered into the database. So it:

Creates an array by looping through the variables that get the form feilds.

Then loops through the array and replaces the ' with '':
Title1=(Replace(Title2, "'", "''"))

View Replies View Related

Array

I'm looking to make an admin page for a web photo gallery, and I need to make a drop down menu showing all files in a given directory that do not have comments in a database for the given filename.

I'm curious about the most efficient way to do this. I don't want to query the database separately for each file as this would be horribly inefficient. I'm thinking about two arrays, one containing all filenames in the photo directory, and one containing filenames from the database that have descriptions.

Is there a simple way in ADO to do a set operation on arrays, that is to produce array C that has all elements in array A that are not contained in array B?I can do this with while loops, but there must be a better way.

View Replies View Related

2D Array

Can someone tell me how to do add a 2D array in a table

this is how my tables looks like

OrderID
Product_Code
Product_Item
Size
Color
Logo
Price
Unit
Total

View Replies View Related

Array Value

How will I replace the array values from database to this javascript static array value?

Quote: var photos = new Array('Blue hills-01.jpg','Sunset-01.jpg','Water lilies-01.jpg','Winter-01.jpg');

View Replies View Related

Add Value To Array

I am editing an old mail script that uses a a sendTO array to designate who actually gets the email. I want to add a value (an email address) at the end of the array so it is sent the same mail as any mail that goes through the form(teh form has one huge dropdown list now).

I just don't know how to simply add the value to the bottom of the list
Any clues (i found some examples but there was way to much extra code that i was having trouble sifting out)?

View Replies View Related

Array

I'm working on a project using arrays like this:
thisArray = array("value1", "value2", "value3")

It's seems to work great, but now I'm confronted with adding to that array at a later point. How can I add to an existing array?

View Replies View Related

How Do Dim Array?

how do you dim a 3d (?) array?

somearray(x,y) ?

View Replies View Related

Populating An Array

I have two recordsets that I want to populate within an array.

The array will always have two columns, but the number of rows is unknown (sometimes 2 rows other times 200 rows). I'm not too familiar working with arrays.

I want populate the array using a loop. How would I define and populate the array within loop so that I don't lose values and each new set of values are populated into the array through each iteration of the loop? Code:

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved