By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,434 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

syntax error

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.