469,917 Members | 1,873 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

syntax error

Hello,

The line below is OK

document.write("<td ID='fred' >" + this.lhs_0[1] + "</td>");

but how do I write the more general version where the 0 is
situation_number and the 1 is count - ie 2 variables?

ie I know the following is wrong!

document.write("<td ID='fred' >" + "this.lhs_" + situation_number +
"[" + count +"1" + "</td>");

How should it be written?

Thanks

Geoff


Sep 12 '05 #1
6 1052
Geoff Cox wrote:
Hello,

The line below is OK

document.write("<td ID='fred' >" + this.lhs_0[1] + "</td>");

but how do I write the more general version where the 0 is
situation_number and the 1 is count - ie 2 variables?

ie I know the following is wrong!

document.write("<td ID='fred' >" + "this.lhs_" + situation_number +
"[" + count +"1" + ;

How should it be written?


<td ID='fred' >"+
window["lhs_" + situation_number][count++]+
"</td>"
Something like that, if "count" is to be incremented and lhs_0 ... _n
series are global variables.
Mick

Mick
Sep 12 '05 #2
ASM
Geoff Cox wrote:
Hello,

The line below is OK

document.write("<td ID='fred' >" + this.lhs_0[1] + "</td>");

but how do I write the more general version where the 0 is
situation_number and the 1 is count - ie 2 variables?

ie I know the following is wrong!

document.write("<td ID='fred' >" + "this.lhs_" + situation_number +
"[" + count +"1" + "</td>");

How should it be written?


I don't know ...

document.write("<td ID='fred' >" + this['lhs_'situation_number[1]] +
"<\/td>");

or

document.write("<td ID='fred' >" +
eval('this.lhs_'+situation_number+'[1]') + "<\/td>");

--
Stephane Moriaux et son [moins] vieux Mac
Sep 12 '05 #3
On Mon, 12 Sep 2005 15:18:03 GMT, Mick White
<mw***********@rochester.rr.com> wrote:
<td ID='fred' >"+
window["lhs_" + situation_number][count++]+
"</td>"


Mick,

Thanks for the above - it works fine but am the following does not
work. Can you explain why for me please then I might grasp why the
first one does work!

Cheers

Geoff

document.getElementById('fred').innerHTML = window["lhs_"
+ situation_number][count];

Sep 12 '05 #4
Geoff Cox wrote:
On Mon, 12 Sep 2005 15:18:03 GMT, Mick White
<mw***********@rochester.rr.com> wrote:

<td ID='fred' >"+
window["lhs_" + situation_number][count++]+
"</td>"

Mick,

Thanks for the above - it works fine but am the following does not
work. Can you explain why for me please then I might grasp why the
first one does work!

Cheers

Geoff

document.getElementById('fred').innerHTML = window["lhs_"
+ situation_number][count];


Try:
alert(count)
alert(window["lhs_" + situation_number][count])
Mick
Sep 12 '05 #5
On Mon, 12 Sep 2005 16:16:48 GMT, Mick White
<mw***********@rochester.rr.com> wrote:
document.getElementById('fred').innerHTML = window["lhs_"
+ situation_number][count];


Try:
alert(count)
alert(window["lhs_" + situation_number][count])


Mick,

trying above I get

1. the alert window with the correct value of teh count variable and
the array value for lhs_0[1] displayed on a new page.

2. I click on the alert OK and get error message

'window[...]' is null or not an object

Thoughts?

Geoff
Sep 12 '05 #6
On Mon, 12 Sep 2005 16:16:48 GMT, Mick White
<mw***********@rochester.rr.com> wrote:
Geoff Cox wrote:
On Mon, 12 Sep 2005 15:18:03 GMT, Mick White
<mw***********@rochester.rr.com> wrote:

<td ID='fred' >"+
window["lhs_" + situation_number][count++]+
"</td>"

Mick,

Thanks for the above - it works fine but am the following does not
work. Can you explain why for me please then I might grasp why the
first one does work!
Mick

Oops! my mistake - some other code left in.

Cheers

Gepff
Cheers

Geoff

document.getElementById('fred').innerHTML = window["lhs_"
+ situation_number][count];


Try:
alert(count)
alert(window["lhs_" + situation_number][count])
Mick


Sep 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Steve | last post: by
1 post views Thread by Donald Canton | last post: by
3 posts views Thread by Manuel | last post: by
1 post views Thread by Hari Sekhon | last post: by
7 posts views Thread by Josh | last post: by
Banfa
5 posts views Thread by Banfa | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.