Results 1 to 2 of 2

Thread: Adding javascript limiting checkboxes checked to post ad step form

  1. #1
    Thread Starter
    chimera's Avatar
    Join Date
    Jun 2012
    Location
    United Kingdom
    Posts
    18
    Thanks
    11
    Thanked 2 Times in 2 Posts

    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 ) . '&nbsp;&nbsp;' . $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

  2. #2
    samcy's Avatar
    Join Date
    Mar 2012
    Location
    Germany
    Posts
    12,098
    Thanks
    121
    Thanked 1,756 Times in 1,442 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Rolf Hassel (Samcy)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to include step> Select a Category: to the 1 step of adding new AD ?
    By lopez85 in forum ClassiPress General Discussion
    Replies: 4
    Last Post: January 11th, 2012, 04:55 AM
  2. Replies: 3
    Last Post: December 19th, 2011, 12:56 PM
  3. Adding ads step-by-step (ajax?)
    By rodeoramsey in forum Report ClassiPress Bugs
    Replies: 2
    Last Post: August 27th, 2010, 10:50 PM
  4. Adding javascript HELP!
    By garyb in forum ClassiPress General Discussion
    Replies: 0
    Last Post: July 22nd, 2010, 12:41 PM