Adding javascript limiting checkboxes checked to post ad step form
Hi All,
WP 3.5.2, CP 3.2
I need to add code to limit the number of checkboxes checked to the 'Step 2' (step2.php) phase of ad submission, preferably using the script at
http://www.willmaster.com/library/ma...box-checks.php. I have successfully used this script in previous versions of CP, but the code has altered significantly. I can register and enqueue the script in functions.php, but need advice how best to add
onclick="CountChecks('varname',max,this)"
to each <li> tag in includes/forms/step-functions.php line 157 (I believe this is the relevant code):
case 'checkbox':
$post_meta_val = ( $post ) ? get_post_meta($post->ID, $result->field_name, false) : array();
$options = explode( ',', $result->field_values );
$options = array_map( 'trim', $options );
$optionCursor = 1;
$html_checkbox = '';
$html_options = '';
foreach ( $options as $option ) {
$field_class = ( $result->field_req ) ? 'checkboxlist required' : 'checkboxlist';
$args = array( 'value' => $option, 'type' => 'checkbox', 'class' => $field_class, 'name' => $result->field_name . '[]', 'id' => $result->field_name . '_' . $optionCursor++ );
if ( in_array($option, $post_meta_val) )
$args['checked'] = 'checked';
$args = apply_filters( 'cp_formbuilder_' . $result->field_name, $args, $result, $post );
$html_checkbox = html( 'input', $args ) . ' ' . $option;
$html_options .= html( 'li', array(), $html_checkbox );
}
echo html( 'ol', array( 'class' => 'checkboxes' ), $html_options );
echo html( 'div', array( 'class' => 'clr' ) );
break;
given that I have two lists, so would need to replace 'varname' with a variable (?). I hope this makes sense. If there is an easier/better way to achieve this, please let me know; I'm not aware of any CP plugin extensions with this capability. Any help will be appreciated