HTML form input tag name element array with JavaScript

前端 未结 5 1782
终归单人心
终归单人心 2020-11-30 03:20

This is a two part question. Someone answered a similar question the other day (which also contained info about this type of array in PHP), but I cannot find it.

1.

5条回答
  •  感情败类
    2020-11-30 04:05

    Try this something like this:

    var p_ids = document.forms[0].elements["p_id[]"];
    alert(p_ids.length);
    for (var i = 0, len = p_ids.length; i < len; i++) {
      alert(p_ids[i].value);
    }
    

提交回复
热议问题