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

Select drop down, better generlized way?

Subject: Select drop down, better generlized way?
From: Mattison <peacock@xxxxxxxxx>
Date: Fri, 22 Aug 2003 15:17:30 -0400 (EDT)
xsl drop down
Greetings

I'm looking for a better more generalized way to handle html drop down
listboxes.  Currently I'm writing code much like below, where I create a
seperate template for each drop down, altering the XPath to the xml
list of label/values ("Status"), name of the select control (status_id),
and initial value for the control ("/Page/Data/Edit/status_id").

The xsl looks like this:

  <xsl:apply-templates select="Status" />
...
  <xsl:template match="Status">
    <select name="status_id">
      <option value=""></option>
      <xsl:for-each select="Option">
        <option>
        <xsl:if test="value = /Page/Data/Edit/status_id">
          <xsl:attribute name="selected">1</xsl:attribute>
        </xsl:if>
        <xsl:attribute name="value">
          <xsl:value-of select="value" />
        </xsl:attribute>
        <xsl:value-of select="label" />
        </option>
      </xsl:for-each>
    </select>
  </xsl:template>

xml:

  <Status>
    <Option>
      <label>Pretest</label><value>4</value>
    </Option>
    <Option>
      <label>Test</label><value>3</value>
    </Option>
  </Status>

I'm hoping there is a way to write a single template where I can call it
several places and somehow pass different values for those three
variables each time.  Any suggestions?

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+      Mattison Narramore                  peacock@xxxxxxxxx      +
+-----------------------------------------------------------------+
+ The most likely way for the world to be destroyed, most experts +
+ agree, is by accident. That's where we come in; we're computer  +
+ professionals. We cause accidents.                              +
+                   -Nathaniel Borenstein                         +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 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.