change attachment custom field onChange event
The form is in post creating window. Ajax is posting values, but the values doenst renews. Where can be problem ?
Ajax
script
function dynamic_Select(field, aid, value)
{
console.log(field, aid,value);
jQuery.ajax({
type: "POST",
url: ajaxurl,
data:{
field: field,
aid: aid,
value: value,
},
error: function(){alert('Error!')},
success: function(){alert(value)}
});
}
/script
functions.php
add_action('wp_ajax_dynselect', 'update_dynamic_select');
add_filter("attachment_fields_to_save", " update_dynamic_select", null , 2);
function update_dynamic_select($field, $aid, $value) {
update_post_meta($aid, $field, $value);
}
HTML:
select aid="104" name="_image_matmenys" onchange="dynamic_Select(this.getAttribute('name'), this.getAttribute('aid') ,this.value)"
option value="10x10"10x10/option
option value="20x20" selected="selected"20x20/option
option value="30x30"30x30/option
/select