expected identifier error

B

barry

sString.Append("document.forms[0]. + name + .style.visibility = 'hidden'" &
vbCrLf)

The above is found in a function which has had name passed to it. This
code is in the asp.net codebehind

The name converts to card17 and would like code to look like this when
converted:

document.forms[0].card17.style.visibility = hidden

Would appreciate any help
thanks
 
C

Chris R. Timmons

sString.Append("document.forms[0]. + name + .style.visibility =
'hidden'" & vbCrLf)

The above is found in a function which has had name passed
to it. This code is in the asp.net codebehind

The name converts to card17 and would like code to look like
this when converted:

document.forms[0].card17.style.visibility = hidden

Would appreciate any help
thanks

Barry,

sString.Append("document.forms[0].");
sString.Append(name);
sString.Append(".style.visibility = 'hidden';");
sString.Append(vbCrLf);
 
B

barry

The problem Chris is that the sString.Append(name) gives an error about not
being declared

Chris R. Timmons said:
sString.Append("document.forms[0]. + name + .style.visibility =
'hidden'" & vbCrLf)

The above is found in a function which has had name passed
to it. This code is in the asp.net codebehind

The name converts to card17 and would like code to look like
this when converted:

document.forms[0].card17.style.visibility = hidden

Would appreciate any help
thanks

Barry,

sString.Append("document.forms[0].");
sString.Append(name);
sString.Append(".style.visibility = 'hidden';");
sString.Append(vbCrLf);
 
C

Chris R. Timmons

The problem Chris is that the sString.Append(name) gives an
error about not being declared

Barry,

What type is sString? Could you post more code that demonstrates the
problem?

Thanks.

Chris.
 
B

barry

Chris here is the code. Basically it presents cards to the page and when I
click on a card I want it to become invisible. (line xx)
I have not given you all the code that goes through numbering the cards etc.
I have done a alert on the name parm and it does show the correct card being
clicked on ----- but how to convert it so line xx accepts it is the
problem.


***********************************************************
Dim sString As System.Text.StringBuilder
sString = New System.Text.StringBuilder

sString.Append("<script language='Javascript'>" & vbCrLf)

sString.Append("document.write(""<img class=setup")
sString.Append(r)
sString.Append(" src=../Solitary/images/")
sString.Append(abc)
sString.Append(" name=card")
sString.Append(r + u)
sString.Append(" id=card")
sString.Append(r + u)
sString.Append(" onclick=MakeInvisible(name)")
sString.Append(" runat = server")
sString.Append(">"");" & vbCrLf)

sString.Append("function MakeInvisible(name) {" & vbCrLf)

line xx sString.Append("(document.forms[0].name.style.visibility =
'hidden')" & vbCrLf)
}
sString.Append("</script>")
***********************************************************
 
C

Chris R. Timmons

Chris here is the code. Basically it presents cards to the page
and when I click on a card I want it to become invisible. (line
xx) I have not given you all the code that goes through
numbering the cards etc. I have done a alert on the name parm
and it does show the correct card being clicked on ----- but
how to convert it so line xx accepts it is the problem.


***********************************************************
Dim sString As System.Text.StringBuilder
sString = New System.Text.StringBuilder

sString.Append("<script language='Javascript'>" & vbCrLf)

sString.Append("document.write(""<img class=setup")
sString.Append(r)
sString.Append(" src=../Solitary/images/")
sString.Append(abc)
sString.Append(" name=card")
sString.Append(r + u)
sString.Append(" id=card")
sString.Append(r + u)
sString.Append(" onclick=MakeInvisible(name)")
sString.Append(" runat = server")
sString.Append(">"");" & vbCrLf)

sString.Append("function MakeInvisible(name) {" & vbCrLf)

line xx
sString.Append("(document.forms[0].name.style.visibility =
'hidden')" & vbCrLf) }
sString.Append("</script>")
***********************************************************

Barry,

So it's the browser's JavaScript that's raising the error,
right? In that case, change line xx to call getElementById:

sString.Append("document.getElementById(name).style.visibility = 'hidden'; }" & vbCrLf)
 
B

barry

Thank you so very much - that sure did the trick - I really appreciate your
time.

Chris R. Timmons said:
Chris here is the code. Basically it presents cards to the page
and when I click on a card I want it to become invisible. (line
xx) I have not given you all the code that goes through
numbering the cards etc. I have done a alert on the name parm
and it does show the correct card being clicked on ----- but
how to convert it so line xx accepts it is the problem.


***********************************************************
Dim sString As System.Text.StringBuilder
sString = New System.Text.StringBuilder

sString.Append("<script language='Javascript'>" & vbCrLf)

sString.Append("document.write(""<img class=setup")
sString.Append(r)
sString.Append(" src=../Solitary/images/")
sString.Append(abc)
sString.Append(" name=card")
sString.Append(r + u)
sString.Append(" id=card")
sString.Append(r + u)
sString.Append(" onclick=MakeInvisible(name)")
sString.Append(" runat = server")
sString.Append(">"");" & vbCrLf)

sString.Append("function MakeInvisible(name) {" & vbCrLf)

line xx
sString.Append("(document.forms[0].name.style.visibility =
'hidden')" & vbCrLf) }
sString.Append("</script>")
***********************************************************

Barry,

So it's the browser's JavaScript that's raising the error,
right? In that case, change line xx to call getElementById:

sString.Append("document.getElementById(name).style.visibility = 'hidden'; }" & vbCrLf)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top