Hi,
Can anyone please advise me on the following. Here I have a bunch of variables in an array. And then those arrays in another array. I want to assign values to those variables in arrays. Is this the correct way to do it? -
<html>
-
<body>
-
-
<script type="text/javascript">
-
-
var a,b,c,d,e,f;
-
var set1=[a,b,c];
-
var set2=[d,e,f];
-
var comboAll=[set1,set2];
-
-
function initializeVars(){
-
-
for (var i=0; i<comboAll.length;i++){
-
-
for (var j=0; j<comboAll[i].length;j++){
-
comboAll[i][j] = 'Hello ' + j ;
-
}
-
}
-
-
document.write('Start wrting variables<br />');
-
document.write(a + '<br />');
-
document.write(b + '<br />');
-
document.write(c + '<br />');
-
document.write(d + '<br />');
-
document.write(e + '<br />');
-
document.write(f + '<br />');
-
-
-
}
-
-
</script>
-
-
</body>
-
<input type='button' value='Initilize' onClick='initializeVars();' />
-
</html>
-
Best regards
7 2136
first, don’t use document.write() after the page finished loading.
@Dormilich
I changed it with a DIV tag. Still doesnt work.
It returns undefined for each variable. -
<div id='results'></div>
-
-
document.getElementById('results').innerHTML = a + ' ' + b + ' ' + c + ' ' + d + ' ' + e + ' ' + f;
-
regards
of course, you never set them anywhere.
Thanks for you reply. I am setting the values for the array variables in the loop. Am i doing something wrong here. -
-
<html>
-
<body>
-
-
<script type="text/javascript">
-
-
var a,b,c,d,e,f;
-
var set1=[a,b,c];
-
var set2=[d,e,f];
-
var comboAll=[set1,set2];
-
-
function initializeVars(){
-
-
for (var i=0; i<comboAll.length;i++){
-
-
for (var j=0; j<comboAll[i].length;j++){
-
comboAll[i][j] = 'Hello ' + j ;
-
}
-
}
-
-
document.getElementById('results').innerHTML = a + ' ' + b + ' ' + c + ' ' + d + ' ' + e + ' ' + f;
-
-
-
-
}
-
-
</script>
-
-
</body>
-
<input type='button' value='Initilize' onClick='initializeVars();' />
-
<div id='results'></div>
-
</html>
-
you don’t. what you’re setting is the comboAll variable, not a to f.
@Dormilich
Indeed thanks for your answers.
Then how do I assign values during the loop to those variables from a to f?
you cannot. you would have to assign a to f manually.
you should better think of a way, to tweak the output (admittedly, you have a very abstract example)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ben |
last post by:
Hi all,
This may sound easy but I'm having trouble assigning values to array
element. My problem is as follows:
m =
for o in m:
# Here first o is 'Peter'.. I want to do something like this:...
|
by: The Plankmeister |
last post by:
Hi there...
Is it possible to write an UPDATE or INSERT query, where the new value comes
from an array? For example:
UPDATE table_a SET column_x =
WHERE column_y = ;
It's a query (for...
|
by: Matt |
last post by:
How do you add up all the values in an array? The length of the array
is variable. Is there a built in function?
|
by: Zitan Broth |
last post by:
Greetings All,
Running pg 7.3.4 and was reading: http://archives.postgresql.org/pgsql-interfaces/2003-09/msg00018.php . Basically want to assign values to an array and then a 2d array.
However...
|
by: K. Deepa |
last post by:
Hi all,
I am using postgresql7.4. How to handle arrays in plpgsql. How can
I pass an array. Is it possible to retrieve values from an array by
indexing it like
argument : '{1,2,3}'
Return...
|
by: Eric Bantock |
last post by:
Very basic question I'm afraid. Once an array has been declared, is there
a less tedious way of assigning values to its members than the following:
myarray=8;
myarray=3;
myarray=4;
myarray=0;...
|
by: anonymous |
last post by:
I have couple of questions related to array addresses. As they belong
to the same block, I
am putting them here in one single post. I hope nobody minds:
char array;
int address;
Questions...
|
by: Nightfarer |
last post by:
Hello.
I have a big trouble using System.Array class (it's the first time I use it) for a software I'm developing.
I have a form with a textbox(numbers) and one button (done).
Once the number...
|
by: sumuka |
last post by:
Hello,
I'm doing a project in java and im not able to assign the values which are got from for loop to the 2-dimensional array.
Can anyone tell me how to assign the values and print them?
the...
|
by: i12know |
last post by:
Hi guys,
I had some problem inserting values a structure array in C++.
I had define for example
struct UNITS {
unsigned char VariableA;
unsigned char VariableB;
// the...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |