Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding multiple attributes to a textbox

Status
Not open for further replies.

dpdoug

Programmer
Nov 27, 2002
455
US
I want to add several events to the attributes of a text box web control so that it renders like this:

Code:
<INPUT TYPE=text onchange="CheckDate(this)" onkeydown="FormatDate(this, window.event.keyCode,'down')" 
onkeyup="FormatDate(this, window.event.keyCode,'up')">

How is this done?

I have tried it using different lines, but one overwrites the other instead of adding to it.

I have found that this doesn't work:

Code:
myText.Attributes.Add("onchange","CheckDate(this)")

myText.Attributes.Add("onkeydown","FormatDate(this, window.event.keyCode,'down')")

myText.Attributes.Add("onkeyup","FormatDate(this, window.event.keyCode,'up')")
 
Did you look at the html source? I created a button and added your attributes and a couple of my own. The html source shows this:
Code:
<input type="submit" name="btn1" value="Button" id="btn1" onclick="return CheckStuff('txt1')" onblur="test()" onchange="CheckDate(this)" onkeydown="FormatDate(this, window.event.keyCode,'down')" onkeyup="FormatDate(this, window.event.keyCode,'up')" />
 
Thanks for responding so quickly. I'll try that out.
 
i'm assuming you're adding javascript attributes...you need to state that here...
Code:
myText.Attributes.Add("onchange","Javascript:CheckDate(this);")

myText.Attributes.Add("onkeydown","Javascript:FormatDate(this, window.event.keyCode,'down');")

myText.Attributes.Add("onkeyup","Javascript:FormatDate(this, window.event.keyCode,'up');")

[/code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top