Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: dropdownlist

From: "Neil Smith [MVP Digital Media]" <neil@------.--->
To: NULL
Date: 4/7/2005 4:51:00 PM
On Wed, 6 Apr 2005 14:38:19 +0200, "Leszek" <marek@z...> wrote:

>Hello!
>Can someone help me?
>I'm looking for sample that shows a dropdownlist in xsl template.
>I have a XML file and i don't know how can i do dropdownlist for choosing 
>records from xml :( 

I did this once for a guy on a PHP list, hack away : 

-------------- hotels.xml --------------------

<?xml version="1.0"?>
<hotels>
	<hotel>
		<id>1</id>
		<name>Bangkok oriental</name>
		<address>50 High Street, Kowloon</address>
		<phone>+12 451 708 3282</phone>	
	</hotel>
	<hotel>
		<id>2</id>
		<name>Hilton Marriott</name>
		<address>2042 Michael Wood Street</address>
		<phone>+44 238 9125467</phone>	
	</hotel>
	<hotel>
		<id>3</id>
		<name>Swallow Royal</name>
		<address>91-97 Royal Fort Crescent</address>
		<phone>+01 208 3209 09903</phone>	
	</hotel>
</hotels>

-------------- hotellist.html -----------------

<html>
<head>
	<title>Demo Hotel Loader</title>
</head>

<body onload="populatelist()">
<script language="javascript1.2">
<!--
oxmlDocument = new ActiveXObject("MSXML2.DOMDocument");
oxmlDocument.load("hotels.xml");
dc=new ActiveXObject("MSXML2.DOMDocument");

function populatelist() {
	var hotels=oxmlDocument.selectNodes("/hotels/hotel");
	if (hotels != null) {
		d=document.forms["hotelupdate"].list;
		d.length=0;
		d[0]=new Option('--Please Select--','',true);
		for (i=0;i<hotels.length;i++) {
			d.length++;
			d[i+1]=new Option();

d[i+1].value=hotels[i].selectSingleNode("id").text;

d[i+1].text=hotels[i].selectSingleNode("name").text;
		}
	}
}

function populatevalues() {
	d=document.forms["hotelupdate"];
// Get hotel ID #
	v=d.list[d.list.selectedIndex].value;
// Use this to read the hotel/phone node having this hotel ID

field=oxmlDocument.selectSingleNode("/hotels/hotel[id='"+v+"']/phone");
// Set form's phone field to the text of this node
	d.phone.value=field.text;
// Now to read the hotel/address node having this hotel ID

field=oxmlDocument.selectSingleNode("/hotels/hotel[id='"+v+"']/address");
// Set form's address field to the text of this node
	d.address.value=field.text;
}

//-->
</script>

<form name="hotelupdate" id="hotelupdate" action="post"
method="http://www.my-server.com/myurl.php" onsubmit="alert('This
would send these values to your website');return false;">
<select name="list" id="list" onchange="populatevalues()"></select>
Phone :
<input type="text" name="phone" id="phone" size="15" maxlength="24" />
<br />
<textarea name="address" id="address" rows="3" cols="40"
wrap="virtual"></textarea>
<br />
<input type="submit" name="submit" id="submit" value="Send !" />
</form>

</body>
</html>






transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent