1

IMAGE OF FORM

HTML:

<select name="birthdate[day]" id="birthdate-day" class="date_class">
    <option value="0"> </option>
     .....
</select>
<select name="birthdate[month]" id="birthdate-month" class="date_class">
    <option value="0"></option>
    ..........
</select>
<select name="birthdate[year]" id="birthdate-year" class="date_class">
    <option value="0"> </option>
    <option value="2015">2015</option>
     ....
</select>

I tried to get data this way, but it didn't works:

var birthdate = $contactForm.getElement('select[name="birthdate"]').getProperty('value');

How to get array from form in JS or Mootools to send it than to PHP? Will be send data to PHP in JSON format.

1 Answers1

1

The problem is with your selector. You are giving a partial name, but with the syntax you are using it expects the complete name.

So try something like:

var birthdate = $contactForm.getElement('select[name^="birthdate"]').getProperty('value');

However this is only going to get you the first element that matches.

So with MooTools, you could do something like:

$$('select[name^=birthdate]')

Or in JS:

document.querySelectorAll('select[name^=birthdate]')

Hope that helps

cwurtz
  • 3,177
  • 1
  • 15
  • 15