|
Subject:
|
Help : combobox in xsl to select value by default
|
|
Posted By:
|
priyatowin
|
Post Date:
|
9/6/2006 10:45:41 PM
|
<xsl:variable name="cmbDefault" select="U"></xsl:variable> <SELECT id="cmbAction" name="cmbAction"> <xsl:element name="OPTION"> <xsl:if test="A = $cmbDefault"> <xsl:attribute name="selected" /> </xsl:if> L </xsl:element> <xsl:element name="OPTION"> <xsl:if test="A = $cmbDefault"> <xsl:attribute name="selected" /> </xsl:if> U </xsl:element> <xsl:element name="OPTION"> <xsl:if test="A = $cmbDefault"> <xsl:attribute name="selected" /> </xsl:if> N </xsl:element> <xsl:element name="OPTION"> <xsl:if test="A = $cmbDefault"> <xsl:attribute name="selected" /> </xsl:if> F </xsl:element> <xsl:element name="OPTION"> <xsl:if test="A = $cmbDefault"> <xsl:attribute name="selected" /> </xsl:if> I </xsl:element> </SELECT> I am using above code to select the default value in the combobox. But its not working.. I am getting only the combobox with options listed. but its not selecting the default value.. Please help..
|
|
Reply By:
|
mhkay
|
Reply Date:
|
9/7/2006 1:55:45 AM
|
The correct way to set the "selected" attribute is
<xsl:attribute name="selected">selected</xsl:attribute>
(the HTML syntax is an SGML shortcut for selected="selected").
I don't know what "A" is in:
<xsl:if test="A = $cmbDefault">
Perhaps you meant a string literal, test="'A' = $cmbDefault", I've no idea what your input is. But whatever it is, you're using the same test for each option, so either they will all be selected or none of them will be selected, which seems quite wrong.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
priyatowin
|
Reply Date:
|
9/7/2006 2:37:46 AM
|
<xsl:variable name="cmbDefault" select="'<xsl:value-of select="A"/>'"> </xsl:variable> <SELECT id="cmbAction" name="cmbAction"> <xsl:element name="OPTION"> <xsl:if test="'L' = $cmbDefault"> <xsl:attribute name="selected" /> </xsl:if> L </xsl:element> <xsl:element name="OPTION"> <xsl:if test="'U' = $cmbDefault"> <xsl:attribute name="selected" /> </xsl:if> U </xsl:element> <xsl:element name="OPTION"> <xsl:if test="'N' = $cmbDefault"> <xsl:attribute name="selected" /> </xsl:if> N </xsl:element> <xsl:element name="OPTION"> <xsl:if test="'F' = $cmbDefault"> <xsl:attribute name="selected" /> </xsl:if> F </xsl:element> <xsl:element name="OPTION"> <xsl:if test="'I' = $cmbDefault"> <xsl:attribute name="selected" /> </xsl:if> I </xsl:element> </SELECT>
I want L,U,N,F,I VALUES TO BE LISTED ON THE combo box. Variable cmbDefault will have anyone value among L,U,N,F,I from XML. So depending on the value in cmbDefault, i want the default value to be set.. Please help.. I am new to XSLT and so if anything not clear plz let me know.. awaiting ur reply.
|
|
Reply By:
|
mhkay
|
Reply Date:
|
9/7/2006 3:15:48 AM
|
><xsl:variable name="cmbDefault" select="'<xsl:value-of select="A"/>'"> </xsl:variable>
You're making things absurdly complicated there (And quite incorrect. Why would you want the value of the variable to be the source code of an XSLT instruction?). I'm not sure where the default value comes from in your XML, but you want something like:
<xsl:variable name="cmbDefault" select="A"/>
where "A" should be replaced by a path expression that selects the value.
Also as I said before, use selected="selected".
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
priyatowin
|
Reply Date:
|
9/7/2006 4:01:37 AM
|
Excellent mhkay.. Thanks a lot... I got the answer..
|
|
Reply By:
|
GISGeek
|
Reply Date:
|
7/1/2008 2:11:10 PM
|
I want to show a list of item names in a table for any selected item in a combobox. List of items are child element of the selected item in an xml document. I am new creating xsl document and java script. By search on web I am able to load the combo box with items for which I need to create table upon user selection. But unable to create a table for selected item in the combobox.
Can any of you help me on this?. Any sample you might have whould be greatly appreciated.
|
|
Reply By:
|
mhkay
|
Reply Date:
|
7/1/2008 5:25:22 PM
|
I imagine your aim is to achieve this effect using HTML (and not, say, using XForms).
XSLT is used to convert the XML into your target vocabulary, whether that is HTML, XForms, or anything else.
If you know what HTML you want to generate, tell us, and we can help you write the XSLT. If you don't know what HTML you want to generate, then this isn't the place to ask: you have an HTML question and should find a suitable forum for it.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
GISGeek
|
Reply Date:
|
7/3/2008 8:37:41 AM
|
Hi,
This is what I am doing. I have list of districts and their associated counties in xml document. I was able to display the information in a tabular format on share point, as web part, using the xml and xsl transformation of xml. Now I need to change the way the county information is dispalyed. Instead of a table with a complete list of districts and associated counties, I need to provide a combo box with all the districts. When the user chooses a district form the combo box, its associated counties information is displayed in a table underneath the combo box. I learnt from,http://aspalliance.com/1067_Creating_a_Menu_Using_XSLT_XML_and_JavaScript.3, I need to create a div layer to hide counties of each district and display them based user selected county. I am trying to do exactly what the author is trying to do. But, only difference is that I am trying do it using combo box. Let me know if you help me now. I appreciate your response and I hope you could help me as much as you could. If not atleast point me to other sources where I could look for some information. Thanks.
|
|
Reply By:
|
samjudson
|
Reply Date:
|
7/3/2008 9:05:38 AM
|
Firstly - why are you posting on the end of someone else's question?
Secondly - this is an XSLT forum - if you want help with Javascript and DHTML then I suggest finding a forum on those topics.
If you know what you are trying to output, and can provide us with examples of your input and output then we can help you with the XSLT.
/- Sam Judson : Wrox Technical Editor -/
|