Home > Backend Development > PHP Tutorial > jquery怎么遍历表单的数据成一个数组

jquery怎么遍历表单的数据成一个数组

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:04:49
Original
1137 people have browsed it

jquery如何遍历表单的数据成一个数组

本帖最后由 wulinag 于 2014-08-10 17:11:21 编辑
<div class="menu"><br /><ul><br /><li><br /><label><span>标题:</span><input type="text" name="conf[title][11407482948]" size="12" value="111"></label><br /><label><span>链接:</span><input type="text" name="conf[url][11407482948]" size="18" value="aaa"></label><br /><label><span>排序:</span><input type="text" name="conf[order][11407482948]" size="2" maxlength="2" value="1"></label><br /></li><br /><li><br /><label><span>标题:</span><input type="text" name="conf[title][31407483086]" size="12" value="222"></label><br /><label><span>链接:</span><input type="text" name="conf[url][31407483086]" size="18" value="bbb"></label><br /><label><span>排序:</span><input type="text" name="conf[order][31407483086]" size="2" maxlength="2" value="2"></label><br /></li><br /><li><br /><label><span>标题:</span><input type="text" name="conf[title][21407483086]" size="12" value="333"></label><br /><label><span>链接:</span><input type="text" name="conf[url][21407483086]" size="18" value="ccc"></label><br /><label><span>排序:</span><input type="text" name="conf[order][21407483086]" size="2" maxlength="2" value="3"></label><br /></li><br /><li><br /><label><span>标题:</span><input type="text" name="conf[title][11407483086]" size="12" value="444"></label><br /><label><span>链接:</span><input type="text" name="conf[url][11407483086]" size="18" value="ddd"></label><br /><label><span>排序:</span><input type="text" name="conf[order][11407483086]" size="2" maxlength="2" value="4"></label><br /></li><br /></ul><br /></div>
Copy after login


jquery如何遍历以下表单的数据成一个数组:
以下是我想得到的数组,用php打印出来的结果
Array
(
    [conf] => Array
        (
            [title] => Array
                (
                    [11407482948] => 111
                    [31407483086] => 222
                    [21407483086] => 333
                    [11407483086] => 444
                )

            [url] => Array
                (
                    [11407482948] => aaa
                    [31407483086] => bbb
                    [21407483086] => ccc
                    [11407483086] => ddd
                )

            [order] => Array
                (
                    [11407482948] => 1
                    [31407483086] => 2
                    [21407483086] => 3
                    [11407483086] => 4
                )
        )
)
------解决方案--------------------
<?php <br />if($_POST) {<br>  echo '<xmp>';<br>  print_r($_POST);<br>  exit;<br>}<br>?><br><script></script><br><br><script><br />$(function() {<br />  f = $('<form>').html($('.menu').html()).serialize();<br />  $.post(location.href, f, function(d) { alert(d) });<br />});<br /></script><br><div>
<br><ul><div class="clear">
                 
              
              
        
            </div></ul>
</div></xmp>
Copy after login
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template