html 多<选择>PHP 帖子中的数组

发布于 2024-09-15 11:38:19 字数 4066 浏览 4 评论 0原文

<form>        
    <input class="date-pick"  type="text" value="2010/08/02" name="date" />
    <table id="events_selection">            
        <tr>                
            <td>                    
                <img src="/admin/ajax/image.php?filename=/media/immagini/danieledaniela/1.jpg&maxw=200" />
                <select name="1">
                    <option value="0"> NESSUN EVENTO </option>                        
                    <option value="5">anelli</option>                        
                    <option value="8">ballo</option>                        
                    <option value="6">cerimonia in chiesa</option>                        
                    <option value="13">dettagli</option>                        
                    <option value="9" selected="selected"><strong>festa</strong></option>                        
                    <option value="4">gli sposi</option>                        
                    <option value="1">la sposa</option>                        
                    <option value="3">lancio del riso</option>                        
                    <option value="2">lo sposo</option>                        
                    <option value="11">preparazione sposa</option>                        
                    <option value="10">preparazione sposo</option>                        
                    <option value="7">ristorante</option>                        
                    <option value="12">varie</option>                        
                </select>
            </td>
            <td>
                <img src="/admin/ajax/image.php?filename=/media/immagini/danieledaniela/30.jpg&maxw=200" />
                <select name="31">
                    <option value="0"> NESSUN EVENTO </option>                        
                    <option value="5">anelli</option>                        
                    <option value="8">ballo</option>                        
                    <option value="6">cerimonia in chiesa</option>                        
                    <option value="13">dettagli</option>                        
                    <option value="9">festa</option>                        
                    <option value="4">gli sposi</option>
                    <option value="1">la sposa</option>                        
                    <option value="3">lancio del riso</option>                        
                    <option value="2">lo sposo</option>                        
                    <option value="11">preparazione sposa</option>                        
                    <option value="10">preparazione sposo</option>                        
                    <option value="7">ristorante</option>                        
                    <option value="12">varie</option>                        
                </select>
            </td>                
        </tr>
    </table>
</form>​​​​​​​​

您好,在这样的情况下(这是一个示例,有很多选择和其他输入)发布此表单将给出这样的 $_POST

array {
  date => "2010/08/09"
  input1 => "bla"
  input3 => "bla2"
  //list of selection
  1 => 2
  2 => 4
  3 => 5
  //ends list of selection
  input 4 => "bla4"
}

我可以直接从 HTML 表单中输入

array {
  date => "2010/08/09"
  input1 => "bla"
  input3 => "bla2"
  //list of selection
  array {
      1 => 2
      2 => 4
      3 => 5
  }
  //ends list of selection
  input 4 => "bla4"
}

谢谢!

<form>        
    <input class="date-pick"  type="text" value="2010/08/02" name="date" />
    <table id="events_selection">            
        <tr>                
            <td>                    
                <img src="/admin/ajax/image.php?filename=/media/immagini/danieledaniela/1.jpg&maxw=200" />
                <select name="1">
                    <option value="0"> NESSUN EVENTO </option>                        
                    <option value="5">anelli</option>                        
                    <option value="8">ballo</option>                        
                    <option value="6">cerimonia in chiesa</option>                        
                    <option value="13">dettagli</option>                        
                    <option value="9" selected="selected"><strong>festa</strong></option>                        
                    <option value="4">gli sposi</option>                        
                    <option value="1">la sposa</option>                        
                    <option value="3">lancio del riso</option>                        
                    <option value="2">lo sposo</option>                        
                    <option value="11">preparazione sposa</option>                        
                    <option value="10">preparazione sposo</option>                        
                    <option value="7">ristorante</option>                        
                    <option value="12">varie</option>                        
                </select>
            </td>
            <td>
                <img src="/admin/ajax/image.php?filename=/media/immagini/danieledaniela/30.jpg&maxw=200" />
                <select name="31">
                    <option value="0"> NESSUN EVENTO </option>                        
                    <option value="5">anelli</option>                        
                    <option value="8">ballo</option>                        
                    <option value="6">cerimonia in chiesa</option>                        
                    <option value="13">dettagli</option>                        
                    <option value="9">festa</option>                        
                    <option value="4">gli sposi</option>
                    <option value="1">la sposa</option>                        
                    <option value="3">lancio del riso</option>                        
                    <option value="2">lo sposo</option>                        
                    <option value="11">preparazione sposa</option>                        
                    <option value="10">preparazione sposo</option>                        
                    <option value="7">ristorante</option>                        
                    <option value="12">varie</option>                        
                </select>
            </td>                
        </tr>
    </table>
</form>​​​​​​​​

HI, in a situation like this (which is an example, there are many selects and other inputs) posting this form would give a $_POST like this

array {
  date => "2010/08/09"
  input1 => "bla"
  input3 => "bla2"
  //list of selection
  1 => 2
  2 => 4
  3 => 5
  //ends list of selection
  input 4 => "bla4"
}

Can I directly from the HTML form put the <select>s in seperate array since they represent a grouped array?

array {
  date => "2010/08/09"
  input1 => "bla"
  input3 => "bla2"
  //list of selection
  array {
      1 => 2
      2 => 4
      3 => 5
  }
  //ends list of selection
  input 4 => "bla4"
}

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

真心难拥有 2024-09-22 11:38:19

这:

<select name="selection[1]">
    <option>1</option>
    <option>2</option>
    <option>3</option>
</select>
<select name="selection[2]">
    <option>1</option>
    <option>2</option>
    <option>3</option>
</select>

会返回:

'selection' => array(1 => 1, 2 => 1)

猜猜这就是您要找的东西? :-)

This:

<select name="selection[1]">
    <option>1</option>
    <option>2</option>
    <option>3</option>
</select>
<select name="selection[2]">
    <option>1</option>
    <option>2</option>
    <option>3</option>
</select>

Would return:

'selection' => array(1 => 1, 2 => 1)

Guess that's what you're looking for? :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文