473,486 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

variablen zusammenfassen

max
ich finde nicht heraus, wie ich drei variablen zu einer zusammenfassen
kann:
3 existierende variablen:
var aa = "einseins";
var ab = "einszwei";
var ac = "einsdrei";
ich möchte die 3 zusammenfassen:
var a3 = aa + ab + ac ; oder
var a3 = (aa,ab,ac) ; oder wie??

vielen dank, max.

Oct 31 '06 #1
8 2662
VK

max wrote:
ich finde nicht heraus, wie ich drei variablen zu einer zusammenfassen
kann:
3 existierende variablen:
var aa = "einseins";
var ab = "einszwei";
var ac = "einsdrei";
ich möchte die 3 zusammenfassen:
var a3 = aa + ab + ac ; oder
var a3 = (aa,ab,ac) ; oder wie??
var a3 = aa + ab + ac ;

or (for strings concatenation):

var a3 = aa.concat(ab, ac);

Oct 31 '06 #2
VK wrote on 31 okt 2006 in comp.lang.javascript:
>
max wrote:
>ich finde nicht heraus, wie ich drei variablen zu einer zusammenfassen
kann:
3 existierende variablen:
var aa = "einseins";
var ab = "einszwei";
var ac = "einsdrei";
ich möchte die 3 zusammenfassen:
var a3 = aa + ab + ac ; oder
Did you try, Max?
>var a3 = (aa,ab,ac) ; oder wie??
Did you try, Max?
var a3 = aa + ab + ac ;

or (for strings concatenation):

var a3 = aa.concat(ab, ac);
Correct,
depending of what is ment by "Variablen zusammenfassen":

<http://dict.leo.org/ende?search=zusammenfassen>
<http://dict.leo.org/ende?search=concatenate>
<http://dict.leo.org/ende?search=addieren>

=========

Perhaps you like this better:

var aa = "einseins";
var ab = "einszwei";
var ac = "einsdrei";
var a3 = [aa,ab,ac].join(' ');

Eins?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 31 '06 #3
max
I don't get it working. here my layout:
var aa = "einseins"; var ab = "einszwei"; var ac = "einsdrei";
var a3 = aa + ab + ac ; // this should sum up the 3 vars above
function showEins() {
for (i = 0; i <=0; i++)
{
// show1 = [aa, ab, ac]; // with i<=2; this works, but is too long in
other cases
show1 = [a3]; // does not work
// var a3 = [aa,ab,ac].join(' '); // did not work either. do I have
to fill in the brackets?
document.getElementById(show1[i]).style.visibility ="visible";
}
}

thank you. max.
Evertjan. schrieb:
VK wrote on 31 okt 2006 in comp.lang.javascript:

max wrote:
ich finde nicht heraus, wie ich drei variablen zu einer zusammenfassen
kann:
3 existierende variablen:
var aa = "einseins";
var ab = "einszwei";
var ac = "einsdrei";
ich möchte die 3 zusammenfassen:
var a3 = aa + ab + ac ; oder

Did you try, Max?
var a3 = (aa,ab,ac) ; oder wie??

Did you try, Max?
var a3 = aa + ab + ac ;

or (for strings concatenation):

var a3 = aa.concat(ab, ac);

Correct,
depending of what is ment by "Variablen zusammenfassen":

<http://dict.leo.org/ende?search=zusammenfassen>
<http://dict.leo.org/ende?search=concatenate>
<http://dict.leo.org/ende?search=addieren>

=========

Perhaps you like this better:

var aa = "einseins";
var ab = "einszwei";
var ac = "einsdrei";
var a3 = [aa,ab,ac].join(' ');

Eins?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 31 '06 #4
Please do not place your text on top of the quoted text.

max <in**@bkom.chwrote:
I don't get it working. here my layout:
var aa = "einseins"; var ab = "einszwei"; var ac = "einsdrei";
Okay, you have 3 variables. Each is a string.
var a3 = aa + ab + ac ; // this should sum up the 3 vars above
This results in

a3 = "einseinseinszweieinsdrei";
function showEins() {
for (i = 0; i <=0; i++)
This doesn't make any sense. After the first run this loop will stop
because ``i'' is greater than zero after ``i++''.
{
// show1 = [aa, ab, ac]; // with i<=2; this works, but is too long in
other cases
Here you create an array with 3 items: ``einseins'', ``einszwei'' and
``einsdrei''.
show1 = [a3]; // does not work
To read the 3rd item of this array you have to write

show1[2]

Arrays are zero based. With your syntax you create an array ``show1''
with 1 item.
// var a3 = [aa,ab,ac].join(' '); // did not work either. do I have
to fill in the brackets?
This results in

a3 = "einseins einszwei einsdrei"
document.getElementById(show1[i]).style.visibility ="visible";
What do you exactly want to do?
thank you. max.
HTH
../otto
--
/"\ ASCII ribbon | http://www.wean.at
\ / campaign against | http://www.lang-kritz.at
x HTML postings | http://www.diepranger.at
/ \ & email |
Oct 31 '06 #5
max

Otto Lang schrieb:
Please do not place your text on top of the quoted text.

max <in**@bkom.chwrote:
I don't get it working. here my layout:
var aa = "einseins"; var ab = "einszwei"; var ac = "einsdrei";

Okay, you have 3 variables. Each is a string.
var a3 = aa + ab + ac ; // this should sum up the 3 vars above

This results in

a3 = "einseinseinszweieinsdrei";
function showEins() {
for (i = 0; i <=0; i++)

This doesn't make any sense. After the first run this loop will stop
because ``i'' is greater than zero after ``i++''.
{
// show1 = [aa, ab, ac]; // with i<=2; this works, but is too long in
other cases

Here you create an array with 3 items: ``einseins'', ``einszwei'' and
``einsdrei''.
show1 = [a3]; // does not work

To read the 3rd item of this array you have to write

show1[2]

Arrays are zero based. With your syntax you create an array ``show1''
with 1 item.
// var a3 = [aa,ab,ac].join(' '); // did not work either. do I have
to fill in the brackets?

This results in

a3 = "einseins einszwei einsdrei"
document.getElementById(show1[i]).style.visibility ="visible";

What do you exactly want to do?
thank you. max.

HTH
./otto
--
/"\ ASCII ribbon | http://www.wean.at
\ / campaign against | http://www.lang-kritz.at
x HTML postings | http://www.diepranger.at
/ \ & email |
thanks for your detailed commentary.
what I need to do is simplifying a dynamic navigation for a website.
the navigation has three hierarchic levels. with each mouse rollover
some field show, others hide. this is defined in js as follows:
----------------------------------
function showEinszwei() {
for (i = 0; i <=7; i++)
{
show1 = ["einseins", "einszwei", "einsdrei",
"einsvier","einszweieins", "einszweizwei", "einszweidrei",
"einszweivier"];
document.getElementById(show1[i]).style.visibility ="visible";
}
for (i = 0; i <=71; i++)
{
hide1 =
["einseinseins","einseinszwei","einseinsdrei","eins dreifuenf",
"einsdreieins", "einsdreizwei", "einsdreidrei", "einsdreivier",
"einsviereins", "einsvierzwei", "einsvierdrei", "einsviervier",
"zweieins", "zweizwei", "zweidrei", "zweivier",
"zweieinseins","zweieinszwei","zweieinsdrei","zwei einsvier","zweizweieins","zweizweizwei",
"zweizweidrei","zweizweivier","zweidreieins","zwei dreizwei","zweidreidrei","zweidreivier",
"zweiviereins","zweivierzwei","zweivierdrei","zwei viervier","dreieins","dreizwei","dreidrei",
"dreivier","dreieinseins","dreieinszwei","dreieins drei","dreieinsvier","dreizweieins","dreizweizwei" ,
"dreizweidrei","dreizweivier","dreidreieins","drei dreizwei","dreidreidrei","dreidreivier","dreiviere ins",
"dreivierzwei","dreivierdrei","dreiviervier","vier eins","vierzwei","vierdrei","viervier","viereinsei ns","viereinszwei",
"viereinsdrei","viereinsvier","vierzweieins","vier zweizwei","vierzweidrei","vierzweivier","vierdreie ins",
"vierdreizwei","vierdreidrei","vierdreivier","vier viereins","viervierzwei","viervierdrei","viervierv ier"];
document.getElementById(hide1[i]).style.visibility ="hidden";
}
}
----------------------------------
as you see, the list under hide1 is far too long. I tried to assign a
variable to each string (var aaa = "einseinseins" ;). thus my hide 1
becomes shorter, but still too long. in a second step I tried to
combine these strings into groups. for instance, all string starting
with "vier..." could be grouped.
thus I hoped, that grouping the three varibles aa, ab and ac (which in
turn represent the strings "einseins", "einszwei" and "einsdrei") into
a new variable called a3. but I failed.
thanks for your help. max.

Oct 31 '06 #6
max wrote on 31 okt 2006 in comp.lang.javascript:
>
Evertjan. schrieb:
[..]
>var a3 = aa + ab + ac ; oder

Did you try, Max?
>var a3 = (aa,ab,ac) ; oder wie??

Did you try, Max?
var a3 = aa + ab + ac ;

or (for strings concatenation):

var a3 = aa.concat(ab, ac);

Correct,
depending of what is ment by "Variablen zusammenfassen":

<http://dict.leo.org/ende?search=zusammenfassen>
<http://dict.leo.org/ende?search=concatenate>
<http://dict.leo.org/ende?search=addieren>

========

Perhaps you like this better:

var aa = "einseins";
var ab = "einszwei";
var ac = "einsdrei";
var a3 = [aa,ab,ac].join(' ');

Eins?
[Please do not toppost on usenet]

I don't get it working. here my layout:
var aa = "einseins"; var ab = "einszwei"; var ac = "einsdrei";
var a3 = aa + ab + ac ; // this should sum up the 3 vars above
You cannot "sum up" strings. You can concatenate them or you can change
them to numerals and then take the sum. Or you can put them in an array
or a collection.

function showEins() {
for (i = 0; i <=0; i++)
{
// show1 = [aa, ab, ac]; // with i<=2; this works, but is too long
in other cases
What do you mean by "to long"?

You do not use the "i" anywhere, so what do you mean?

show1 = [a3]; // does not work
What do you expext it to do?
It surely works, will be the same as:

var show1 = new Array(a3);

// var a3 = [aa,ab,ac].join(' '); // did not work either. do I have
to fill in the brackets?
No, see below
document.getElementById(show1[i]).style.visibility ="visible";
That is very nice but has nothing to do with the above, I think.
}
}
Try this as a seperate file
[in general do not fill in adviced code in your not working code,
till you have tested it on its own]

========= test1.html =============
<script type='text/javascript'>
var aa = "einseins";
var ab = "einszwei";
var ac = "einsdrei";
var a3 = [aa,ab,ac].join(' ');

alert(a3)

</script>
=================================

Tested IE7

Does that "work" [= show the result string in an alert box]?

thank you. max.
Perhaps you want to do this:

========= test2.html =============
<table border=1><tr>
<td style='visibility:hidden;' id='einseins'>einseins</td>
<td style='visibility:hidden;' id='einszwei'>einszwei</td>
<td style='visibility:hidden;' id='einsdrei'>einsdrei</td>
</tr></table>

<script type='text/javascript'>
var aa = "einseins";
var ab = "einszwei";
var ac = "einsdrei";
var a3 = [aa,ab,ac];

function showEins() {
for (i = 0; i <=2; i++) {
document.getElementById(a3[i]).style.visibility ="visible";
};
};

setTimeout('showEins()',3000);

</script>
=================================

Tested IE7

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 31 '06 #7
VK
depending of what is ment by "Variablen zusammenfassen":

By taking into account the response at
<http://groups.google.com/group/comp.lang.javascript/msg/70885fa51c7937ff>
we may translate "zu zusammenfassen" as "to finding the minimum subset
of elements corresponding to the given criteria" or (with the easiness
German solves such minor lexical problems which nocks me down every
time unless I'm there long enough and unless I had a pint of Metzkater
before to hear it :-) that could be expressed as "zu
zusammenelentenausmachen".

To OP: actually arrays may have several "dimensions" and this is
what just scream asking to you:

[
// former eins
[
// former zwei
[
// former drei
]
]

]

Oct 31 '06 #8
max <in**@bkom.chwrote:
thanks for your detailed commentary.
what I need to do is simplifying a dynamic navigation for a website.
the navigation has three hierarchic levels. with each mouse rollover
some field show, others hide. this is defined in js as follows:
function showEinszwei() {
for (i = 0; i <=7; i++)
{
show1 = ["einseins", "einszwei", "einsdrei",
"einsvier","einszweieins", "einszweizwei", "einszweidrei",
"einszweivier"];
document.getElementById(show1[i]).style.visibility ="visible";
}
for (i = 0; i <=71; i++)
{
hide1 =
["einseinseins","einseinszwei","einseinsdrei","eins dreifuenf",
"einsdreieins", "einsdreizwei", "einsdreidrei", "einsdreivier",
"einsviereins", "einsvierzwei", "einsvierdrei", "einsviervier",
[ too long ... snipped ]
}
}
as you see, the list under hide1 is far too long.
That's right.
I tried to assign a variable to each string (var aaa = "einseinseins"
;). thus my hide 1 becomes shorter, but still too long. in a second
step I tried to combine these strings into groups. for instance, all
string starting with "vier..." could be grouped.
You could try to group the items with regular expressions. If you are
not familiar with RegExp take a look at

<http://de.selfhtml.org/javascript/objekte/regexp.htm>
<http://de.selfhtml.org/navigation/syntax.htm#javascript>

and the functions test(), replace(), ...
thanks for your help. max.
HTH
../otto
--
/"\ ASCII ribbon | http://www.wean.at
\ / campaign against | http://www.lang-kritz.at
x HTML postings | http://www.diepranger.at
/ \ & email |
Nov 2 '06 #9

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

Similar topics

4
2966
by: mooneater | last post by:
Hallo, ich bin neu mit dem Umgang mit PHP, und ich habe folgendes (siehe unten) programmiert. Nun erhalte ich bei Aufruf meiner PHP-Datei folgende Fehlermeldung: Parse error: parse error,...
4
6314
by: aaapaul | last post by:
Hallo ! Ich hab schon einiges in den Newsgroups bzgl. Variablenübergabe an ein Formular gelesen. Public Sub in Formular, die vom Modul aus aufgerufen wird. Unter...
0
2133
by: Phil Stanton | last post by:
I am using an imageList control for a tree menu. Works fine Problem I have is using VB to populate the ImageList Basically I have a table of Icons that I wish to use. They point to a folder...
0
1057
by: Phil Stanton | last post by:
Help I have a form where I am trying to load Icons to subsequently display in a Tree menu system. The following 2 bits of code are run on the OnOpen Event after clearing out the old images. The...
0
7132
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,...
0
7180
jinu1996
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...
0
5439
agi2029
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,...
1
4870
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...
0
4564
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
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 ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.