Connecting Tech Pros Worldwide Forums | Help | Site Map

2 Radio btn with one Submit btn, convert to Two Buttons

Familiar Sight
 
Join Date: Sep 2006
Posts: 142
#1: Aug 15 '08
Hi, I don't know xslt - i just need a modification done to existing xslt file.

At the moment the page has 2 radio buttons with a submit button, which exeutes the code dependant on the radio option selected.


Can anyone please help: I want to convert this to two buttons:

<!-- This is the original code -->
<xsl:if test="$cTrigger &gt; '1'">
<xsl:for-each select="Activity/ObjectGroup[@type='trigger']/Object">

<xsl:element name="asp:RadioButton">
<xsl:attribute name='id'><xsl:value-of select='@name' /></xsl:attribute>
<xsl:attribute name='runat'>server</xsl:attribute>
<xsl:attribute name='GroupName'>triggers</xsl:attribute>
<xsl:if test="Value[. = 'on']">
<xsl:attribute name='Checked'>True</xsl:attribute>
</xsl:if>
</xsl:element>

</xsl:for-each>
</xsl:if>

<xsl:if test="$cTrigger &gt; '0'">
<xsl:element name="asp:Button">
<xsl:attribute name="id">___Submit</xsl:attribute>
<xsl:attribute name="runat">server</xsl:attribute>
<xsl:attribute name="text">Submit</xsl:attribute>
<xsl:attribute name="CommandName">Submit</xsl:attribute>
</xsl:element>
</xsl:if>

This is what I tried, by setting the value of ( test="Value[. = 'on']" ) onClick

<xsl:if test="$cTrigger &gt; '1'">
<xsl:for-each select="Activity/ObjectGroup[@type='trigger']/Object">

<xsl:element name="asp:Button">
<xsl:attribute name='id'><xsl:value-of select='@name' /></xsl:attribute>
<xsl:attribute name="onClick">
<xsl:test="Value[. = 'on']"></xsl:test>
<xsl:attribute name='Checked'>True</xsl:attribute>
</xsl:attribute>
<xsl:attribute name="runat">server</xsl:attribute>
<xsl:attribute name="text">Submit</xsl:attribute>
<xsl:attribute name="CommandName">Submit</xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:if>

Please help converting this as i'm not sure what i'm doing but i'm trying to set the "test" value.

Regards

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,657
#2: Aug 28 '08

re: 2 Radio btn with one Submit btn, convert to Two Buttons


Quote:

Originally Posted by ismailc

This is what I tried, by setting the value of ( test="Value[. = 'on']" ) onClick

note on test: what you put in quotation marks has to be an expression. "Value[. = 'on']" means: if there (current node) exists an element named "Value" that has an (can not identify type) named "." whose value is "on", do something.
To me this does not make sense (so to the parser).

the correct expression depends on what element you want to test. example:
Expand|Select|Wrap|Line Numbers
  1. // xml snippet
  2. <button value="on" />
  3. // xsl expression
  4. <xsl:if test="button[@value = 'on']"></xsl:if>
  5.  
  6. // another xml
  7. <button>
  8.   <value>on</value>
  9. </button>
  10. // xsl expression
  11. <xsl:if test="button[value = 'on']"></xsl:if>
if you can provide us with the appropriate xml snippet, we can have a look at the matter again, otherwise we're lost in the woods.

PS: wildcard character is *; . refers to current node, but you can use it only on start of expression or inside xpath functions (e.g. ".", "./parent::*", "name(.)")
Reply