开发者

html multi <select> array in PHP post

<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 s开发者_StackOverflowelection
  array {
      1 => 2
      2 => 4
      3 => 5
  }
  //ends list of selection
  input 4 => "bla4"
}

Thanks!


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? :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜