0

Hi I'm having trouble sending html form array to JS. I have dynamic html form and some fields:

<div id="fields">
<input type="text" name="ppav[]" id="p" />
<input type="text" name="quantity[]" id="q" size="3" />
<input type="text" name="price[]" id="pr" size="10" />
<input type="text" name="sum" id="su" size="10" disabled="disabled"/>
<br />
</div>

in JS i tried using this function but getting undefined alert instead of result:

var welements = document.getElementsByName('ppav[]');
for (var i = 0, j = welements.length; i < j; i++) {
    var an_element = welements[i];
    alert(an_element.selectedIndex);
}
1
  • 5
    Why are you trying to pull selectedIndex from a text input? Commented Jul 10, 2012 at 16:53

1 Answer 1

3

What did you expect? the selectedIndex property returns the index of the selected option in a select element. If you want the value of your input fields, try alert(an_element.value);

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

Comments

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.