if you are using it in a metabox then you really don’t need this part:
onchange="document.location.href=this.options[this.selectedIndex].value;"
So change the select fields to:
<select name="event-dropdown">
<option value=""><?php echo esc_attr(__('Select Event')); ?></option>
<?php
//get saved data
$saved_cat = get_post_meta($post_id,'event-dropdown',true);
$categories= get_categories('child_of=10');
$select_options="";
foreach ($categories as $category) {
$option = '<option value="'.$category->cat_ID.'">';
$option .= $category->cat_name;
$option .= '</option>';
$select_options .= $option;
}
//set saved data as selected
$select_options = str_replace('value="'.$saved_cat.'"','value="'.$saved_cat.'" selected="selected"',$select_options);
echo $select_options;
?>
</select>
then make sure you save it in your membership_meta_box_save
function so add this to the end of it:
if( isset( $_POST['event-dropdown'] ) )
update_post_meta( $post_id, 'event-dropdown', $_POST['event-dropdown'] );
now the category id will be saved as a meta for each page