php - How to access form element xyz[] in Javascript? -
i have code automatically add new similar row defined in form clicking add button.
<html> <body> <form> <input type="text" name="quantity[]" class="input_text" id="pro"/> </form> </body> </html>
now want access different values of quantity[]
in javascript function .
how access different values of quantity[]
in javascript using it's id or name attribute.
<script> function abc() { var id = document.getelementbyid("pro").value; } </script>
you can this.
html:
<form> <input name="p_id[]" value="0"/> <input name="p_id[]" value="1"/> <input name="p_id[]" value="2"/> </form>
javascript:
var p_ids = document.forms[0].elements["p_id[]"]; alert(p_ids.length); (var = 0, len = p_ids.length; < len; i++) { alert(p_ids[i].value); }
Comments
Post a Comment