Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 19th, 2008, 01:25 PM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Default Check if dropdown readonly property is "true"

Hi, how does when check if a dropdwon readonly value is set to true!
I imported an CSS for my dropdwon but now when user says disable it does not work - i need xslt to check if readonly property has changed the add this code to only that field
          var z=dhtmlXComboFromSelect("<xsl:value-of select='$Name' />");
          z.disable(true);

The problem is also that the user sets the property after the page is loaded - is this possible - please assist!



  <xsl:template name="ListValueType">
      <xsl:param name="Name" />
      <xsl:param name="Attributes" />
      <xsl:param name="Options" />
      <xsl:param name="Value" />
        <xsl:element name="asp:dropdownlist">
          <xsl:attribute name='id'>
            <xsl:value-of select='$Name' />
          </xsl:attribute>
          <xsl:attribute name='runat'>server</xsl:attribute>
          <xsl:for-each select="$Attributes/Attribute">
            <xsl:attribute name='{@name}'>
              <xsl:value-of select='.' />
            </xsl:attribute>
          </xsl:for-each>
          <xsl:for-each select='$Value/Options/Option'>
            <xsl:element name="asp:ListItem">
              <xsl:attribute name='Value'>
                <xsl:value-of select='.' />
              </xsl:attribute>
              <xsl:if test="@selected[. = 'true']">
                <xsl:attribute name='selected'>true</xsl:attribute>
              </xsl:if>
              <xsl:value-of select='.' />
            </xsl:element>
          </xsl:for-each>
        </xsl:element>
        <script TYPE='text/javascript'>
          var z=dhtmlXComboFromSelect("<xsl:value-of select='$Name' />");
          z.disable(true);
        </script>
</xsl:template>

 
Old January 19th, 2008, 04:39 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Remember that the XSLT code is generating an HTML page. It can't react to things the user does because it has finished executing long before the user sees the page. You can generate script in the HTML page that responds to user events, but the XSLT code itself can't respond to user input.

I think your code would be so much more readable if you used literal result elements in place of xsl:element and xsl:attribute:

<asp:dropdownlist id="{$Name}" runat="server">
  <xsl:copy-of select="@*"/>
  <xsl:for-each select="$Value/Options/Option">
    <asp:ListItem Value="{.}">
      <xsl:if test="@selected='true'">
        <xsl:attribute name="selected">selected</xsl:attribute>
      </xsl:if>

etc

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 21st, 2008, 04:18 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Hi, Thank You for the help - really appreciate it.

But i have to apologize for the unnecessary post as i just thought of another method instead of struggling to get this going.

I simply just have to check if it has to be disable - then make it not visible & show a text box with it's value!

Thank You

Regards






Similar Threads
Thread Thread Starter Forum Replies Last Post
Property dropdown box in C# code-behind in VS jayaraj123 C# 2005 1 April 5th, 2007 12:54 AM
readonly checkbox Dj Kat HTML Code Clinic 3 November 10th, 2006 08:34 AM
How to set textbox property to readonly when text bekim Classic ASP Basics 1 July 12th, 2005 12:06 AM
Setting ReadOnly Property Values Gavin265 General .NET 8 May 19th, 2005 12:49 PM
setting the ReadOnly property with a function creative_eye General .NET 3 May 10th, 2004 03:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.