Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2005
    Location
    Scotland
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JavaScript if problems with XML

    Heya,

    In my code at the moment I have a repeater that's getting values from my XML document and displaying them in a table. I wanted to exclude some of these values so that they only appeared once and I decided to use a JavaScript if statement to do it, this is what I came up with:

    Code:
          <script language="jscript">
            var store = nil;
            var framec = nil;
          </script>
          <asp:XmlDataSource id="ds1" runat="server" DataFile="XMLFile.xml" />
          <asp:repeater ID="repeater1" DataSourceid="ds1" runat="server">
            <HeaderTemplate><table></HeaderTemplate>
            <ItemTemplate>
             script language="jscript">
                document.write("test");
                if ((store!=(<%#XPath("@type")%>)) || (framec != <%#XPath("@frame")%>)) {
                  document.write('<tr><td>Framed <%#XPath("@type")%></td></tr>');
                  store = <%#XPath("@type")%>;
                  framec = <%#XPath("@frame")%>;
                }
                store = <%#XPath("@type")%>;
                framec = <%#XPath("@frame")%>;
              </script>          <tr>
                <td><%#XPath("@size")%></td>
                <td><asp:TextBox runat="server" Text='<%#XPath("width")%>'></asp:TextBox> X             
                <asp:TextBox ID="TextBox1" runat="server" Text='<%#XPath("height")%>'></asp:TextBox></td>
              </tr>
            </ItemTemplate>
            <FooterTemplate></table></FooterTemplate>
          </asp:repeater>

    However, what it comes up with isn't quite what I had in mind. The javascript only seems to run for the last 3 entries of my XML, that "test" I put in the javascript only appears 3 times. The parts of my itemtemplate that are not in the JavaScript run fine, and I don't know why!

    I'd be very grateful for any assistance!

    Snow

  • #2
    New Coder
    Join Date
    Jun 2005
    Location
    Scotland
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Well, I got it fixed... the problem was to do with my XML file I believe (and some dodgy JavaScript coding), but it's doing exactly what I wanted it to do now!

    Sorry for bothering ya all!

    Snow


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •