Hello,
I have a XML file with following schema.
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="people.xsl"?>
<PEOPLE>
<PERSON>
<NAME>Mark Wilson</NAME>
<ADDRESS>Australia</ADDRESS>
<TEL>12345</TEL>
<FAX>12345</FAX>
<EMAIL>
[email protected]</EMAIL>
</PERSON>
<PERSON>
.....
</PERSON>
</PROPLE
AND BELOW GOES MY people.xsl file.
What I am trying to achieve here is first only the names will be displayed in a combobox and on selecting the name its details are displayed. how do i go about it?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<head>
<title>People XML File</title>
<link rel="stylesheet" href="myStyle.css" />
<h2>My Address Book</h2>
<script language="Javascript" type="text/javascript">
function ChangeData(id)
{
var w = document.getElementById(id).selectedIndex;
var name = document.getElementById(id).options[w].value;
alert(name);
<xsl:variable name="name">
<xsl:attribute name="select">name</xsl:attribute>
</xsl:variable>
<xsl:if test="PEOPLE/PERSON/NAME=$name">
document.write('<br>EMail-Address : <xsl:value-of select="EMAIL"/></br>');
</xsl:if>
}
</script>
</head>
<select class="fontStyle" id="names" onchange="ChangeData('names')">
<xsl:for-each select="PEOPLE/PERSON">
<option>
<xsl:attribute name="value">
<xsl:value-of select="NAME"/>
</xsl:attribute>
<xsl:value-of select="NAME"/>
</option>
</xsl:for-each>
</select>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Regards,
Mahboob