Move the -
loadData();
fillCountries();
Into the body, after the elements, or start them with onload. The DOM of the
body has not loaded yet, so there is no form named "form".

☆PhistucK


On Sun, Jan 3, 2010 at 17:17, Thomas <[email protected]> wrote:

> Hi,
>
> I am really stuck while trying to fill content from an external xml
> file to a select box. Loading the data via XMLHttpRequest works fine
> but I somehow can't get it managed to populate this data as content of
> a select box.
>
> The error message I get is: Uncaught TypeError: Cannot read property
> 'selCountries' of undefined
>
> but I really don't understand what this wants to tell me. SelCountries
> is my select box. Any help is really much appreciated.
>
> Thanks
> Thomas
>
> My manifest file is quite simple and looks like:
>
> {
>  "name": "simple test",
>  "description": "",
>  "version": "1.0",
>
>  "browser_action": {
>    "default_icon": "donate.png",
>    "default_title": "simple test",
>    "popup": "popup.html"
>  }
> }
>
>
> The popup.html is also quite simple and looks like:
>
> <html>
> <head>
> <script type="text/javascript">
> var xmlDoc;
> var url = chrome.extension.getURL("data.xml");
>
> function loadData()
> {
>        var req = new XMLHttpRequest();
>    req.open('GET', url, false);
>    req.send(null);
>        xmlDoc = req.responseXML;
> }
>
> function fillCountries()
> {
>        var i = 0;
>        while (i < xmlDoc.getElementsByTagName("exp").length)
>        {
>                document.form.selCountries.options
> [document.form.selCountries.length] = new Option
> (xmlDoc.getElementsByTagName("exp")[i].getAttribute
> ("display"),xmlDoc.getElementsByTagName("exp")[i].getAttribute
> ("country"));
>                i++;
>        }
> }
>
> loadData();
> fillCountries();
>
> </script>
> </head>
> <body>
> <FORM NAME="form" ACTION="" METHOD="GET"">
>  <table border = "0">
>        <tr>
>          <td width="55"><p class="small">Country: </p></td>
>          <td valign="middle">
>                <select name="selCountries" size="1" STYLE="width:
> 260px"></select>
>                <img src="accept.png" width="16" height="16" alt="Def.
> Country"
> title="Def. Country">
>          </td>
>        </tr>
>        <tr>
>          <td width="55"><p class="small">Hours: </p></td>
>          <td>
>                <select name="selHours" size="1">
>                  <option value="8">8-14h</option>
>          <option value="14">14-24h</option>
>                  <option value="24">24h</option>
>                </select>
>                <span class="small">Breakfast:</span><input type="checkbox"
> name="breakfast" id="breakfast">
>          </td>
>        </tr>
>        <tr>
>          <td></td>
>          <td>
>                <br>
>                <INPUT TYPE="button" NAME="btnCalc" Value="Calculate" >
>                <INPUT TYPE="button" NAME="btnClear" Value="Clear" >
>          </td>
>        </tr>
>  </table>
> </FORM>
> </body>
> </html>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<chromium-extensions%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en.


Reply via email to