I am still learning javascript and xml and have recently been presented with an issue I’m sure is simple to solve. I’m hoping for some help on this if possible.
I have an xml file that is found here
http://mrblesid.com/blueprint/bookinglist.xml
I’m currently using this code to create a drop down list featuring the values from just one of the attributes “strArtistName”
$(document).ready(function(artists){
$.ajax({
type: "GET",
url: "bookinglist.xml",
dataType: "xml",
success: function(artists_list) {
var select = $('#mySelect');
$(artists_list).find('vw_ADM_BookingListNull[strArtistName]').each(function(){
var artists = $(this).attr('strArtistName');
select.append('<option value="'+artists+'">'+artists+'</option>');
});
select.children(":first").text("please make a selection").attr("selected",true);
}
});
});
This is then called into a dropdown via the following
<form>
<select id="mySelect">
<option>loading</option>
</select>
</form>
I would like to avoid repeating the artist names that are found for every entry, am I right to think I would need to use an array for this? If so how do I go about it?
The name selected from the list should populate a variable to use elsewhere in the report.
Any help would be greatly appreciates as I have deadlines looming.
Thanks in advance,
Mikey
An array will work. Update the main part to
Some browsers don’t support
Array.indexOf, so you can use jQuery’sinArray.