I am trying to write an array that adda a number to the array on the click of a button, this is so i can send a series of numbers to a second page.
im just not sure how to do it???
never used arrays
11 1730
I'm not aware that an array can write something to another array..... you probably mean function. you can use an array method ( Array – MDC), e.g. - your_array.push(new_value);
regards
what i need is the array to contain a series of numbers
i.e 123,234,345 etc
will the push function do this?
The idea is that the array holds the id for things on our site so you can click them as a favorite and then view all favorites from another page....a bit like a shopping cart
let me explain the push() method: - var my_array = [1,2];
-
// my_array now contains 1,2
-
alert(my_array.length); // 2
-
my_array.push(3);
-
// my_array now contains 1,2,3
-
alert(my_array.length); // 3
note: you know that numbers are not allowed for IDs?
regards
So i could do something like this -
var my_array = [];
-
// my_array now contains nothing
-
my_array.push(123);
-
// my_array now contains 123
-
then if i wanted to add another number -
my_array.push(456);
-
// my_array now contains 123,456
-
Is this correct???
Also would you know how to get the amount stored in the array item from an asp variable
eg the 123 or 456 to come from asp ID
@colinod
yes @colinod
sorry, I can't help with ASP, you should ask in the ASP forum for help
I have got the array being populated with an asp variable but how can i get the page to display the content of my_array, i have tried -
-
<script language="javascript">
-
document.write(my_array);
-
</script>
-
in the body of the page but get nothing displayed
you could try the Array.toString() or Array.toSource() method (see toString – MDC)
I dont think thats quite what im looking for, i need a way of taking each entry into the array and having it appear in the html on my page, its just so i can see if the array is holding all the information
well, that's what the functions do, show you the content (i.e. returning the content)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David |
last post by:
I have an array that contains numbers in string elements , i want to convert
this to integers, i have made a for loop that uses the number of elements in
the array and then adds 0, thereby...
|
by: HolaGoogle |
last post by:
Hi all,
Please help me with the following..it's realy urgent and i tried
everything i could and i can't get it work properly!! Thanks in
advance.
Here's what i'm trying to accomplish:
in my...
|
by: Troy |
last post by:
Hello,
I have a dumb question. I have two array objects of type double with 12
elements in each object. I'd like to add the two objects but dont know how
to. Any ideas?
thanks
|
by: Sri |
last post by:
How do you add an n-bit number in C?
Regards,
Sri
|
by: Brian Piotrowski |
last post by:
Hi All,
I've probably done this before, but for the life of me I can't remember how
I did it. I need to move values from a DB table into an array to be used
for other queries. The number of...
|
by: Paul_Madden via DotNetMonster.com |
last post by:
Basically I have a listbox to which I add simple STRING items- I have a
progress bar which I increment whenever I populate another portion of the
complete set of items I wish to add. What I observe...
|
by: Chris Lieb |
last post by:
I am trying to add an event listener to the keyup event for some text
inputs that I am creating dynamically. I have no problems getting it
to work in Firefox, but IE just ignores them. I have...
|
by: mtchatchez |
last post by:
I have several 2-dimensional arrays which I want to sum the values of, returning an array that has for each of its values the sum from all the others (if that makes sense?) ... Okay ... maybe an...
|
by: dennis.sprengers |
last post by:
Consider the following multi-dimensional array:
---------------------------
$arr = array(
array(3, 5, 7, 9),
array(2, 4, 6, 8),
array(1, 3, 5, 7)
);
function add_arrays($arr) {
for ($row =...
|
by: AndyW2387 |
last post by:
Hi
I'm quite a newbie and have been struggling with sessions (!)
What I'm trying to do is to add submitted values from a textfield (or ID number) to an array which is in a $_SESSION. ( It's for a...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |