[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Re: xsl and checkbox

Subject: RE: Re: xsl and checkbox
From: cknell@xxxxxxxxxx
Date: Wed, 09 Oct 2002 16:38:21 -0400
checkbox xsl
Here are sample xml, xsl, and html files:
#####################################
<?xml version="1.0"?>
<root>
  <item id="1" checked="true">fruits</item>
  <item id="2" checked="false">cereals</item>
  <item id="3" checked="false">legumes</item>
  <item id="4" checked="true">tubers</item>
</root>
######################################
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html" indent="yes" encoding="UTF-8" />
  <xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>
  <xsl:template match="root/item">
    <xsl:element name="input">
      <xsl:if test="@checked='true'">
        <xsl:attribute name="checked">true</xsl:attribute>
      </xsl:if>
      <xsl:attribute name="id"><xsl:value-of select="@id" /></xsl:attribute>
      <xsl:attribute name="type">checkbox</xsl:attribute>
      <xsl:attribute name="value"><xsl:value-of select="." /></xsl:attribute>
      <xsl:value-of select="." />
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
######################################
  <input checked="true" id="1" type="checkbox" value="fruits">fruits</input>
  <input id="2" type="checkbox" value="cereals">cereals</input>
  <input id="3" type="checkbox" value="legumes">legumes</input>
  <input checked="true" id="4" type="checkbox" value="tubers">tubers</input>
######################################

You could use JavaScript to inspect the "checked" attribute by using this DOM programming technique:

if(document.getElementById("1").checked){
 ... whatever you need to do here
}

Is this clear, or does it require further explanation?
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     "Frans Herbst" <fherbst@xxxxxxxxxxxxx>
Sent:     Wed, 9 Oct 2002 21:33:12 +0200
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  Re:  xsl and checkbox

> When you say "reference it with javascript", do you mean you want to
inspect it after it is loaded on the browser, or during the transformation
to HTML?

Well the easiest possible, I need to populate a string with all the selected
items when I submit the page.
If I could check anytime if the checkbox is selected I could populate a
hidden list box with the info, but everthing I have tried results to an
unidentifier to the listbox or attribute I defined for the listbox.

Any help on this would be very much appreciated.

 Frans Herbst



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.