Apologies in advance - the title may not adequately describe the problem i'm attempting to solve.
I have the following javascript script
Code:
<script type="text/javascript">
var text_st = new Array("Client 1", "Client2", "Client3", "Client4", "Client5", "Client6");
var l = text_st.length;
var rnd_no = Math.floor(l*Math.random());
document.write('<span class="BodyText">');
document.write('<a href="#">');
document.write(text_st[rnd_no]);
document.write('</a>');
document.write('</span>');
</script>
This script simply displays any of Client1 to Client6 every time the page is refreshed.
I am attempting to replace the values of Client1 to Client6 with xml.
SO far i have done the following...
Code:
<script type="text/javascript">
var text_st = new Array("<xsl:for-each select='$dcr/spotlight'><xsl:value-of select='name'/>,</xsl:for-each>");
var l = text_st.length;
var rnd_no = Math.floor(l*Math.random());
document.write('<span class="InterflowBodyText">');
document.write('<a href="#">');
document.write(text_st[rnd_no]);
document.write('</a>');
document.write('</span>');
</script>
This has returned all the values of $dcr/spotlight/name in the page rather than randomly displaying one value when the page is refreshed.
The other question is that I need to value in the href tag to be the corresponding url(of the page) of the Client name.
My xml is below....
Code:
<?xml version="1.0" encoding="UTF-8" ?>
- <Properties Admin="true" ComponentID="">
- <Data>
- <Datum ID="D001" Name="D00" Type="DCR">
- <DCR Category="Customer" Type="Customerspotlight">
- <customerspotlight>
- <spotlight>
<name>client1</name>
<page>client1.page</page>
</spotlight>
- <spotlight>
<name>client2</name>
<page>client2.page</page>
</spotlight>
- <spotlight>
<name>client3</name>
<page>client3.page</page>
</spotlight>
- <spotlight>
<name>client4</name>
<page>client4.page</page>
</spotlight>
- <spotlight>
<name>client5</name>
<page>client5.page</page>
</spotlight>
- <spotlight>
<name>client6</name>
<page>client6.page</page>
</spotlight>
- <spotlight>
<name>client7</name>
<page>client7page</page>
</spotlight>
</customerspotlight>
</DCR>
</Datum>
</Data>
</Properties>
Thanks in advance