0

I am building a plugin for the WordPress, and I have a screen that need to manipulate the data of multiple dimensional array names. More specific, I have the input elements like the following:

<div class="settingsContainer">
    <input type="button" class="edit" value="Edit" />
    <input type="hidden" name="initialFare[1][title]" value="Initial fare">
    <input type="hidden" name="initialFare[1][rate]" value="2.25">
    <input type="hidden" name="initialFare[1][description]" value="">
    <input type="hidden" name="initialFare[1][whenType]" value="always">
</div>
<div class="settingsContainer">
    <input type="button" class="edit" value="Edit" />
    <input type="hidden" name="initialFare[2][title]" value="Initial fare II">
    <input type="hidden" name="initialFare[2][rate]" value="2.25">
    <input type="hidden" name="initialFare[2][description]" value="Hello">
    <input type="hidden" name="initialFare[2][weekday][]" value="Mo">
    <input type="hidden" name="initialFare[2][weekday][]" value="We">
    <input type="hidden" name="initialFare[2][weekday][]" value="Th">
    <input type="hidden" name="initialFare[2][startHour]" value="00:02">
    <input type="hidden" name="initialFare[2][endHour]" value="23:56">
    <input type="hidden" name="initialFare[2][whenType]" value="dayshours">
</div>

Now, the problem is, how to iterate over the weekdays of the second settingsContainer, and in general, how can I write my selectors for multiple dimensional array names. Is there any good tutorial for writing name selectors ? Any idea ?

1 Answer 1

2

Use this selector :

$('input[name="initialFare[2][weekday][]"]')

See the documentation on jQuery selectors

Sign up to request clarification or add additional context in comments.

3 Comments

This will return an array with all the records related to ?
What do you mean by record ? This will let you iterate over the three elements having this name.
I mean with any input field that contain this name. I suppose yes eh ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.