Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assigning variables to attributes

Status
Not open for further replies.

jonthequik

Programmer
Aug 6, 2000
40
0
0
US
I'm trying to use XML to design a table.&nbsp;&nbsp;I want this table to be sortable based on an option the user enters on the page itself.&nbsp;&nbsp;I've got it to where the user's request is posted to the page (sort of), but need to pass the variable to the attribute.&nbsp;&nbsp;The problem is that my current coding has the order-by attribute sorting by the variable itself, not the value assigned to it.&nbsp;&nbsp;What am I missing?<br><br>In the code below, I have the script capture the value from another frame.&nbsp;&nbsp;I need the order-by attribute to sort the database by that value.&nbsp;&nbsp;How?<br><br>&lt;?xml version='1.0'?&gt;<br>&lt;xsl:stylesheet xmlns:xsl=&quot;<A HREF=" TARGET="_new"> match=&quot;/&quot;&gt;<br>&nbsp;&nbsp;&lt;html&gt;<br>&lt;script language=&quot;JavaScript&quot;&gt;<br>function notReady() {<br> aa = parent.one.document.form1.sortCards.selectedIndex;<br> alphaName = parent.one.document.form1.sortCards.options[aa].value;<br> bb = parent.one.document.form1.sortOrder.selectedIndex;<br> bravoName = parent.one.document.form1.sortOrder.options[bb].value;<br> sortValue = bravoName + alphaName;<br> alert(sortValue);<br>}<br>&lt;/script&gt;<br>&nbsp;&nbsp;&lt;body bgcolor=&quot;white&quot; text=&quot;black&quot;&gt;&lt;CENTER&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;H1&gt;Triple Triad Card List&lt;/H1&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;table border=&quot;1&quot; bgcolor=&quot;white&quot; BORDERCOLOR=&quot;black&quot; CELLPADDING=&quot;3&quot; CELLSPACING=&quot;0&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th align=&quot;left&quot;&gt;Monster&lt;/th&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th align=&quot;left&quot;&gt;Lvl&lt;/th&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th align=&quot;left&quot;&gt;Elemental&lt;/th&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th align=&quot;left&quot;&gt;Class&lt;/th&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th align=&quot;left&quot;&gt;Mod&lt;/th&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th align=&quot;left&quot;&gt;T&lt;/th&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th align=&quot;left&quot;&gt;L&lt;/th&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th align=&quot;left&quot;&gt;B&lt;/th&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th align=&quot;left&quot;&gt;R&lt;/th&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:for-each select=&quot;TRIPLETRIAD/CARD&quot; order-by=&quot;sortValue&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;xsl:value-of select=&quot;NAME&quot;/&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;xsl:value-of select=&quot;LEVEL&quot;/&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;xsl:value-of select=&quot;ELEMENTAL&quot;/&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;xsl:value-of select=&quot;CLASSIFICATION&quot;/&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;xsl:value-of select=&quot;MODIFICATION&quot;/&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;xsl:value-of select=&quot;TOP&quot;/&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;xsl:value-of select=&quot;LEFT&quot;/&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;xsl:value-of select=&quot;BOTTOM&quot;/&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;xsl:value-of select=&quot;RIGHT&quot;/&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsl:for-each&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/table&gt;&lt;/CENTER&gt;<br>&nbsp;&nbsp;&lt;/body&gt;<br>&nbsp;&nbsp;&lt;/html&gt;<br>&lt;/xsl:template&gt;<br>&lt;/xsl:stylesheet&gt;<br>
 
Dear jonthequick,<br><br>&gt; What am I missing?<br><br>Wow that's a tough question. First this:<br><br>&gt; order-by=&quot;sortValue&quot;&gt;<br><br>is never going to work since &quot;sortValue&quot; is just text and nothing more. It does not reference the variable in your script in any way. That said, I don't think there is support in XSL to do that in any syntax.<br><br>As far as I am aware there is no way to marry client script and XSL the way you appear to be trying to do it. But I will admit that I don't feel comfortable that I clearly understand what solution you are trying to build.<br><br>In the Microsoft browser 5+ versions you can access the XMLDOM ActiveX interfaces from client side script. But the script needs to be in the encompasing HTML document that houses the XML and XSL ActiveX control elements. At least that's the way I currently understand it.<br><br>Here is a short example from MSDN:<br>&lt;HTML&gt;&nbsp;&nbsp;<br>&lt;HEAD&gt;&nbsp;&nbsp;&nbsp;&nbsp;<br>&lt;TITLE&gt;Simple Error Message Demo&lt;/TITLE&gt;&nbsp;&nbsp;<br>&lt;/HEAD&gt;&nbsp;&nbsp;<br>&lt;XML id=&quot;source&quot; src=&quot;review.xml&quot;&gt;&lt;/XML&gt;<br>&lt;XML id=&quot;style&quot; src=&quot;review.xsl&quot;&gt;&lt;/XML&gt;&nbsp;&nbsp;<br>&lt;SCRIPT src=&quot;reportErrors.js&quot;&gt;&lt;/SCRIPT&gt;&nbsp;&nbsp;<br>&lt;SCRIPT event=&quot;onload&quot; for=&quot;window&quot;&gt;<br>if (source.parseError.errorCode != 0)<br>result = reportParseError(source.parseError);&nbsp;&nbsp;&nbsp;&nbsp;<br>else{<br>if (style.parseError.errorCode != 0)<br>result = reportParseError(style.parseError);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>else{<br>try {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>result = source.transformNode(style.XMLDocument);<br>}catch (exception) <br>{<br>result = reportRuntimeError(exception);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>}&nbsp;&nbsp;&nbsp;&nbsp;<br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>// insert the results into the page&nbsp;&nbsp;&nbsp;&nbsp;<br>showResult.innerHTML = result;<br>&nbsp;&nbsp;<br>&lt;/SCRIPT&gt;&nbsp;&nbsp;<br>&lt;BODY&gt;&nbsp;&nbsp;&nbsp;&nbsp;<br>&lt;DIV id=&quot;showResult&quot;&gt;&lt;/DIV&gt;&nbsp;&nbsp;<br>&lt;/BODY&gt;&lt;/HTML&gt;<br><br><br>Hope this helps<br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top