Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.java.* > Newsgroup comp.lang.javascript

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 01-01-2007, 11:27 PM
avanti
Guest
 
Posts: n/a
Default HyperLink text property undefined

HI,
I have a HyperLink in my code. It has a OnClick function defined. I am
trying to access the text property of the HyperLink in my JavaScript
function.

<CoreCtrl:Controls.WebControls.HyperLink id="securityCodeLink" text="My

Text" OnClick="ShowText(this);" Href="#" CssClass="textSmall"
runat="server" />

function ShowText(obj)
{
alert(obj.text);
}

I also tried getting a var for the hyperlink with its id and showing
its text. It says 'undefined' instead of 'My Text'. Am I doing
something wrong?

Thanks,
Avanti

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 01-01-2007, 11:38 PM
Chad Burggraf
Guest
 
Posts: n/a
Default Re: HyperLink text property undefined

avanti wrote:

> function ShowText(obj)
> {
> alert(obj.text);
> }
>
> I also tried getting a var for the hyperlink with its id and showing
> its text. It says 'undefined' instead of 'My Text'. Am I doing
> something wrong?


There is no default property called "text" for anchor elements. You
should use innerHTML as follows:

function ShowText(obj) {
alert(obj.innerHTML);
}
Reply With Quote
  #3 (permalink)  
Old 01-01-2007, 11:50 PM
Jim
Guest
 
Posts: n/a
Default Re: HyperLink text property undefined

Avanti,
You can determine the text attribute value in this manner:
<a href="#"
text="sometext should go here"
onClick="alert(this.getAttribute('text'))"
>

Show the Text Attribute Value
</a>

Hope that helps,

Jim

Reply With Quote
  #4 (permalink)  
Old 01-02-2007, 12:04 AM
avanti
Guest
 
Posts: n/a
Default Re: HyperLink text property undefined

Thanks guys for the quick reply. It worked!

Jim wrote:
> Avanti,
> You can determine the text attribute value in this manner:
> <a href="#"
> text="sometext should go here"
> onClick="alert(this.getAttribute('text'))"
> >

> Show the Text Attribute Value
> </a>
>
> Hope that helps,
>
> Jim


Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Heiracical Parsing Exercise Arthur Tabachneck Newsgroup comp.soft-sys.sas 0 05-09-2006 03:18 AM
Re: Heiracical Parsing Exercise Jiann-Shiun Huang Newsgroup comp.soft-sys.sas 0 05-08-2006 11:42 PM
Heiracical Parsing Exercise Michael Murff Newsgroup comp.soft-sys.sas 0 05-08-2006 10:49 PM
Re: SAS/AF: Validate Text Entry Control after user leaves field Randy Herbison Newsgroup comp.soft-sys.sas 0 12-16-2005 10:55 PM
LayPerson's-Macro 101: Re: Passing by reference Terjeson, Mark Newsgroup comp.soft-sys.sas 0 12-13-2005 04:33 PM



All times are GMT. The time now is 12:07 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.