[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Select drop down, better generlized way?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|