Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: dropdownlist [Thread Next] Re: dropdownlistTo: NULL Date: 4/22/2005 2:30:00 PM Thank you very much!
Uzytkownik "Neil Smith [MVP Digital Media]" <neil@n...> napisal w
wiadomosci news:1gqa51tm54vmtdukevgddb4u4i427f8off@4......
> 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>
>
>
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
