dooberry Posted March 6, 2006 Share Posted March 6, 2006 I'm a bit bemused (see above!!).I'm trying to restrict a <for-each> element based on the value a user enters in a particular node.I've tried the following:<xsl:template match="selectfilter" ><xsl:variable name="var1" select="elementpath" /><select name="filteredselect" ><xsl:for-each select="filterselection[filterelement={$var1}]"><option><xsl:value-of select="element" /></option></xsl:for-each></select></xsl:template> I keep getting an error because of the variable reference, if someone could tell me where I'm being a little bit *naff* I'd appreciate it.Dooberry scented eau de toilette. The longest journey begins with a single step - or you could just sit on your a**e and watch TV with some beers Link to comment Share on other sites More sharing options...
dooberry Posted March 9, 2006 Author Share Posted March 9, 2006 I fixed it:I had to get rid of the braces {} around the variable in the filter condition.I also made an explicit reference to the document containing the value I needed to filter on so it ended up something like this: <xsl:variable name="var1" select="Document('userdata.xml')//root/element" /><select id="dropdownbox"> <xsl:for-each select="Document('listoptions.xml')//root/optionelement[filterelement=$var1]"> <option> <xsl:attribute name="value"> <xsl:value-of select="optionvalueelement" /> </xsl:attribute> <xsl:value-of select="descriptionelement" /> </option> </xsl:for-each></select> This allowed me to use one file as a set of options for a select control and another file to control which of the options appeared, based on what the user had already entered. I'm nearly ready to start scripting this to write back to a database now so thanks to everyone who has helped with these posts. I hope any code I've submitted has been useful - feel free to give me any feedback.As we say in the West Midlands "Taraah a bit bab!!"Dooberry. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now