Click to See Complete Forum and Search --> : dynamic href
CG-Sparrow
11-30-2003, 03:52 PM
i am attempting to create a dynamic href link.
the user selects an option from a select list, which in turn changes the properties associated with a button.
when a user clicks on this button, a corresponding sound associated with their selection starts to play/download.
the sounds and the list (plus numerous other items) are all stored in a 2D array - abt 1100 entries
sadly i am restricted to client side scripts only.
if ne1 can suggest a solution i would be most grateful.
Dan
What does your array look like?
CG-Sparrow
11-30-2003, 04:00 PM
arrSinglesData =
[["Manic Street Preachers","The Masses Against The Classes",0,"22/01/2000",1,"covers/The_Masses_Against_The_Classes.jpg","tracks/The_Masses_Against_The_Classes.wma","1. Masses against the classes","","",""],
["Britney Spears","Born To Make You Happy",0,"29/01/2000",1,"covers/Born_To_Make_You_Happy.jpg","tracks/Born_To_Make_You_Happy.wma","1. Born to make you happy","2. You drive me crazy","3. Baby one more time (MC)",""],
...];
its a 2d array containing data about uk chart singles since january 2000.
the reference needs to point to arrSinglesData[i][6];
where i is the value returned from the select list.
btw thx for such a quick reply
CG-Sparrow
11-30-2003, 04:07 PM
i came up with a sort of solution its not ideal by any means:
just using
location.href = arrSinglesData[choice.value][6];
it opens a windowsmedia window.
im going to play with this, but create a button to start a function and one to stop it.
You could try something like this:
<script type="text/javascript">
arrSinglesData = new Array()
arrSinglesData[0] = new Array("Manic Street Preachers","The Masses Against The Classes",0,"22/01/2000",1,"covers/The_Masses_Against_The_Classes.jpg","tracks/The_Masses_Against_The_Classes.wma","1. Masses against the classes","","","");
arrSinglesData[1] = new Array("Britney Spears","Born To Make You Happy",0,"29/01/2000",1,"covers/Born_To_Make_You_Happy.jpg","tracks/Born_To_Make_You_Happy.wma","1. Born to make you happy","2. You drive me crazy","3. Baby one more time (MC)","");
function setVals() {
for (i=0; i<arrSinglesData.length; i++) {
sel = document.getElementById('songs');
newopt = new Option(arrSinglesData[i][1],arrSinglesData[i][6]);
if (document.all) { //IE method
sel.add(newopt,sel.options.length);
}
else { //DOM method
sel.add(newopt,sel.options[sel.options.length]);
}
}
}
onload = setVals;
</script>
</head>
<body>
<form action="">
<p><select id="songs" onchange="this.form.action = this.options[this.selectedIndex].value;">
<option value="">Please Choose</option>
</select>
<input type="submit" name="submit" value="submit"></p>
</form>
CG-Sparrow
11-30-2003, 04:34 PM
thank you, its a great help
yours gratefully
dan