|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
XML Select boxes
Hi,
I know this is a really stupid question, but it would be the job if someone could help me. All I want to do is take data like <?xml version="1.0"?> <?xml-stylesheet href="sharing.xsl" type="text/xsl"?> <users> <user name="Test User1" location="http://www.test1.com/~test1"/> <user name="Test User2" location="http://www.test2.com/~test2"/> </users> and display it using an XSL stylesheet so that the name attributes are listed in a select box and the location attribute is linked to by that element. If that makes sense. Basically when you click on Test User1 you go to URL Really appreciate it if anyone knows what to do. Gunners11 |
|
#2
|
||||
|
||||
|
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head>
<script>
<![CDATA[
function users_onChange(cboUsers)
{
location.href = cboUsers.value;
}
]]>
</script>
</head>
<body>
<xsl:call-template name="printUsersDropdown">
<xsl:with-param name="usersNode" select="users"/>
</xsl:call-template>
</body>
</html>
</xsl:template>
<xsl:template name="printUsersDropdown">
<xsl:param name="usersNode"/>
<select id="users" onchange="users_onChange(this);">
<option>Select a user ...</option>
<xsl:for-each select="$usersNode/user">
<option value="{@location}"><xsl:value-of select="@name"/></option>
</xsl:for-each>
</select>
</xsl:template>
</xsl:stylesheet>
|
|
#3
|
|||
|
|||
|
Thank You
Thanks for that MattSidesinger
Really Appreciate it, worked perfectly. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XML Select boxes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|