🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.javascript
1 messages
1 total messages Started by foka Thu, 22 Apr 2010 12:39
dane z pliku XMl do <select> nie dziala lokalnie
#50001
Author: foka
Date: Thu, 22 Apr 2010 12:39
47 lines
1978 bytes
Czesc. Mam problem a kiepski z Ajaxa jestem
Chce pole selecta i option wypelniac grupą danych z xml
Wszystko jest spoko ale dziala tylko jak odpale na serwerze, a 
potrzebuje by bylo przenosne i dzialalo np odpalana z plytki czy na 
kazdym windowsie bez instalacji apache.
Moj kod:
             function showGroups()
             {
                 var url_file="../xml/groups.xml";
                 xmlDoc=loadXMLDoc(url_file);	//wczytuje dane

                 var groupXml = xmlDoc.getElementsByTagName("group");	
                 for (var i=0; i < groupXml.length; i++) {
                     document.forms['searchForm'].grupy.options[i] = new 
Option(groupXml[i].firstChild.nodeValue,groupXml[i].firstChild.nodeValue);
                 }
             }
             window.onload=showGroups;

W htmlu mam tylko to:

<select name="grupy" class="grupy">
</select>

A plik XML jest taki:
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<group>AK</group>
<name>COS AK</name>
</item>
<item>
<group>BZ</group>
<name>COS BZ</name>
</item>
<item>
<group>CA</group>
<name>COS CA</name>
</item>
</items>

Czy ktos podpowie mi jak zrobic by dzialalo to lokalnie.



Pozdrawiam
foka
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads