Since the value
values are saved at the href
attribute, use:
$("a.cli").click(function(event){ //when anchor is clicked
event.preventDefault();
$(".ui-datepicker-month").val($(this).attr("href"));
});
Try this:
...
<a onClick="$('select.ui-datepicker-month').val('1');">Feb</a>
...
<select class="ui-datepicker-month">
...
<option value="1">Feb</option>
...
</select>
Why change the value and not select the option that has the "clicked" value?
<a class="cli" href="0">Jan</a>
<a class="cli" href="1">Feb</a>
<a class="cli" href="2">Mar</a>
<select id="month" name="month" class="ui-datepicker-month">
<option value="0">Jan</option>
<option value="1">Feb</option>
<option value="2">Mar</option>
</select>
Script:
jQuery('a.cli').click(function(event) {
event.preventDefault();
jQuery('#month option').attr('selected', false);
jQuery('#month option[value="' + jQuery(this).attr('href') + '"]').attr('selected', true);
});
Check it out http://jsfiddle.net/jchiotaka/uaLXU/