View Full Version : JavaScript if problems with XML

01-23-2006, 12:59 PM

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;
<asp:XmlDataSource id="ds1" runat="server" DataFile="XMLFile.xml" />
<asp:repeater ID="repeater1" DataSourceid="ds1" runat="server">
script language="jscript">
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><asp:TextBox runat="server" Text='<%#XPath("width")%>'></asp:TextBox> X
<asp:TextBox ID="TextBox1" runat="server" Text='<%#XPath("height")%>'></asp:TextBox></td>

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!


01-23-2006, 08: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!