Skip to content

JS function wpsc_meta_item_change() causes *all* checkboxes in a list to be the same #2072

@jbeales

Description

@jbeales

If someone adds a list of checkboxes to the checkout form, the HTML is something like:

<label><input type="checkbox" name="collected_data[21][]" value="i-am-on">Check Me</label>
<label><input type="checkbox" name="collected_data[21][]" value="i-am-on-as-well">Only check me if you want.</label>

Notice how the name attribute is the same - this is as designed, to send an array to PHP. However, the JS function wpsc_meta_item_change() fires on the JS change event and makes all inputs with the same name attribute have the same value, or in the case of a checkbox be checked or unchecked. The function is here.

For array inputs all values should not be synchronized, however, if the array exists in more than one place on the page it would make sense to synchronize the arrays with each other, (although I think PHP would just end up with an array that's twice as long & confusing).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions