...

View Full Version : JavaScript if problems with XML



snow
01-23-2006, 11:59 AM
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:


<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

snow
01-23-2006, 07:19 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum