Code:
//querying the campaigns
$campaigns = $wpdb->get_results(
"SELECT *
FROM tbl_campaigns
ORDER BY campaignID DESC",
OBJECT_K
);
//displaying the campaigns
<select name="campaign_list" class="campaign_dropdown">
<?php
foreach($campaigns as $c):
echo '<option value="'.$c->campaignID.'" rel="'.$c->campaignID.'">'.$c->campaign_name.'</option>';
endforeach;
?>
</select>
//javascript/jquery
var $j = jQuery.noConflict();
$j('.campaign_dropdown').change(function(){
if($j(this).val() != '0'){
var rel = $j(this).closest('option').attr('rel');
alert(rel);
  }
});
What i want to do is just to display the ‘s rel value whenever i select from the dropdown.
but what i always get is an undefined message.
(if this will be fixed, i’ll be using it to load another page whenever i select from the dropdown)
What’s wrong with the code?
I think you want: