Friday, January 2, 2009

[jQuery] change()

Hello all,
a little new the js and jquery any help would be fantastic...

I have this in my linked myFx.js file:

$(document).ready(function() {
var selected_type = $('select#campaign_type_select');
var coupon_div = $('#campaign_create_coupon');
var broadcast_div = $('#campaign_create_broadcast');
var contest_div = $('#campaign_create_contest');

// alert(selected_type.val()); << I CAN GET THIS TO FIRE WHEN
UNCOMMENTED, and it returns the the value coupon as i would expect.

BUT THIS ISNT WORKING ive tried various renditions (this.val(),
selected_type, etc...) based on what i have read on this site and the
jQuery site with 0 success.

selected_type.change(function() {
if (this.val() == 'contest') {
alert('contest');
}
else if (this.val() == 'broadcast') {
alert('broadcast');
}
else (this.val() == 'coupon') {
alert('coupon');
}
});
});

This is the HTML:
<div class="form_data_wrap">
<div class="form_data_label">Campaign Type:</div>
<div class="form_data_value">
<select id="campaign_type_select">
<option value="coupon">Coupon</option>
<option value="broadcast">Broadcast</option>
<option value="contest">Contest</option>
</select>
</div>
</div>

Someone point me in the right direction.....\m/>.<\m/

No comments:

Post a Comment