I am trying to call the following script on a plugin admin page:
<?php
function add_match_attendance_scripts() {
$output = '<script type="text/javascript">
jQuery(function () {
$("#seatt_start").datepicker({dateFormat: "dd-mm-yy"});
$("#seatt_expire").datepicker({
dateFormat: "dd-mm-yy",
firstDay: 1,
onSelect: function (prev_date) {
prev = prev_date.split("-");
var date = new Date(prev[2], prev[1] - 1, prev[0]);
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var new_date = new Date(y, m, d - 7);
$("#seatt_start").removeAttr("disabled").datepicker("setDate", new_date);
}
});
});
</script>';
echo $output;
}
add_action('admin_head','add_match_attendance_scripts');
?>
I already have enqueued jquery-ui-datepicker
for all admin pages and it works correctly on all admin pages using a similar function:
add_action('admin_head','add_report_custom_scripts');
function add_report_custom_scripts() {
global $report_custom_meta_fields, $post;
$output = '<script type="text/javascript">
jQuery(function() {';
foreach ($report_custom_meta_fields as $field) { // loop through the fields looking for certain types
// date
if($field['type'] == 'date')
$output .= 'jQuery(".datepicker").datepicker({ dateFormat: "dd-mm-yy", firstDay: 1 });';
}
$output .= '});
</script>';
echo $output;
}
but apparently this script runs on my plugin page and not the one I wanted. So how can I specify which script goes where seeing as they are both admin pages?