Javascript question

Mondeo

Well-known member
Joined
Nov 10, 2006
Messages
128
Location
Sunny Lancashire
Hi,

I want to clear a textbox out when its clicked client side, so ive got

[VB]txtExtraOptionDesc.Attributes.Add("onclick", "if(this.value == Description must be entered) this.value = ;")[/VB]

It works fine.

But I also want to set the backcolor to white, can the onclick support more than one action?

I tried

[VB]txtExtraOptionDesc.Attributes.Add("onclick", "if(this.value == Description must be entered) this.value = ;this.backcolor=white")[/VB]

But it didnt work, then again the syntax may be wrong as im not hot on JS.
 
Curly braces {}

The syntax would be:

[VB]txtExtraOptionDesc.Attributes.Add(
"onclick",
"if (this.value == Description must be entered) {this.value = ; this.backcolor=white;}"
)[/VB]

The curly braces allow you to enclose more than one statement, as in all C-style languages.

Good luck :)
 
Back
Top