I have this code which is looking for an onchange event:
//Create destination switch
$('#regionselect').change(function(){
var selected = $(this).find(':selected');
$('.optionvalue').fadeOut(function(){
$('.optionvalue').html(selected.html()).fadeIn()
.attr('class', 'optionvalue '+selected.val());
});
var count = $('.countrylist').length;
$('.countrylist').slideUp(function(){
if(!--count) {
$('.'+selected.val()).slideDown();
}
});
});
It works perfectly here:
http://jsfiddle.net/XfPv7/1/
Can anyone help?
Your real problem is this:
http://www.thestc.co.uk/assets/js/form.js
The scripts found here include the functions
populateSelectOptions(),selectMe(),showOptions(), which together serve to defeat your real select onChange event handler, since you are not interacting with your real select at all.If you kill the select replace scripts, it works fine. See: http://jfcoder.com/test/customselect.html
EDIT
Here’s kind’ve a brute-force way to fix the issue.
http://jfcoder.com/test/customselect.html
All this does is change the Javascript injected into the A.HREF, which is the root problem. This simulates the changing of the value and then triggers on the onChange event.
Note, for some reason jQuery is not loading on every page load for that link on my site, so if it doesn’t work the first time, reload the page after it has entirely loaded.