is it possible to have double nested input tag arrays in html?

后端 未结 2 1244
暗喜
暗喜 2020-12-17 19:26

I\'m wondering before I attempt to refactor my page if its possible to have a double nested input array in html. I have an 8X5 group of elements in a form and it would be ni

2条回答
  •  眼角桃花
    2020-12-17 19:41

    You are going to need to supply indexes into the first part of each field or else there is nothing to nest, and if it did work, it wouldn't look like a grid on the other end:

    Row 1:

     name="list[0][]"
    

    Row 2:

     name="list[1][]" 
    

    etc.

    Finally, your server needs to support this as PHP and Rails do out of the box. I am not sure about other server technologies. For an example, the following HTML when posted to PHP:

    If in the PHP the following code exists:

    
    

    The output is:

    Array
    (
        [0] => Array
            (
                [0] => 1
                [1] => 2
                [2] => 3
            )
    
        [1] => Array
            (
                [0] => 4
                [1] => 5
                [2] => 6
            )
    
        [3] => Array
            (
                [0] => 7
                [1] => 8
                [2] => 9
            )
    
    )
    

提交回复
热议问题