Connecting Tech Pros Worldwide Forums | Help | Site Map

Use the value of name to an html button onclick click function.

Familiar Sight
 
Join Date: Sep 2006
Posts: 142
#1: Oct 15 '09
Good day,

I need to use the value of the name to an html button onclick click function.

Expand|Select|Wrap|Line Numbers
  1. <xsl:element name="asp:CheckBox">
  2.    <xsl:attribute name='id'><xsl:value-of select='@name' /></xsl:attribute>     
  3.    <xsl:attribute name='runat'>server</xsl:attribute>
  4. </xsl:element>
  5.  
  6. <input id="btnDone" type="button" value="Done" onClick="@name.click();">
I want to onclick the button click the checkbox.
This does not work onClick="@name.click();"
but say the id of the checkbox = Test then onClick="Test.click();" works

Please help!

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,660
#2: Oct 15 '09

re: Use the value of name to an html button onclick click function.


Quote:

Originally Posted by ismailc View Post

This does not work onClick="@name.click();"

simple reason, the XPath expression (@name) only works on elements whose attribute value is parsed as such. i.e. the expression must be a) placed in an XSL element and b) the attribute denotes an XPath expression (select, match, test, …)

the best solution IMHO would be an external Javascript file (i.e. resign from using inline Javascript).
Familiar Sight
 
Join Date: Sep 2006
Posts: 142
#3: Oct 15 '09

re: Use the value of name to an html button onclick click function.


I got it going :)
Thank You

Expand|Select|Wrap|Line Numbers
  1. {@name}.click();
  2.  
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,660
#4: Oct 15 '09

re: Use the value of name to an html button onclick click function.


Quote:

Originally Posted by ismailc View Post

Expand|Select|Wrap|Line Numbers
  1. {@name}.click();

right… didn’t remember ’cause I hardly use those (despite the fact I don’t use inline Javascript either)
Familiar Sight
 
Join Date: Sep 2006
Posts: 142
#5: Oct 15 '09

re: Use the value of name to an html button onclick click function.


Thank You for helping :)
Reply