我正在开发一个典型的约会网站,例如男性/女性在所有或选定的省份中寻找年龄为x和y的男性/女性。为此,我有以下代码:
<form action="<?php echo url_for('password/listmatches' ) ?>" method="post" >
<tr>
<td colspan="2">
<span class='spn_med_lightblue_rbc'>I am a:</span>
<select id="gender1" >
<option value="male1" >Male</option>
<option value="female1" selected="selected">Female</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<span class='spn_med_lightblue_rbc'>Seeking a:</span>
<select id="gender2">
<option value="male2" >Male</option>
<option value="female2" selected="selected">Female</option>
</select>
</td>
</tr>
<tr>
<td>
<span class='spn_med_lightblue_rbc'>Age:</span>
<select id="age1" >
<option value="eighteen" selected="selected">18</option>
<option value="nineteen">19</option>
<option value="twenty">20</option>
<option value="twentyone">21</option>
</select>
</td>
<td>
<span class='spn_med_lightblue_rbc'>To:</span>
<select id="age2" >
<option value="hunderd" selected="selected">100</option>
<option value="ninetynine" >99</option>
<option value="eightyeight" >88</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<span class='spn_med_lightblue_rbc'>Location:</span>
<select id="provinces" >
<option value="all" selected="selected">All</option>
<option value="ec">Eastern Cape</option>
<option value="nc">Northern Cape</option>
<option value="wc">Western Cape</option>
<option value="fs">Free State</option>
<option value="gp">Gauteng</option>
<option value="kzn">Kzn</option>
<option value="lim">Limpopo</option>
<option value="mpu">Mpumulanga</option>
<option value="nw">North West</option>
</select>
</td>
<td><input class='submit_img' type="image" src="/images/rainbow/gobuttonbluesmall.png" value="Submit" alt="Submit"></td>
</tr>
<tr></tr>
<tr></tr>
</form>
如何将所选内容(如果有)发布到:url_for('password / listmatches'? 我无法进行onChange,因为用户可能只是根据表单保留选择并按下go按钮。我需要根据下一个表格中选择的内容制作一个列表。
有什么建议吗? 谢谢
答案 0 :(得分:1)
提交表单时,只有具有名称的表单控件才会实际发送到服务器。您的选择控件没有名称,因此不会发布。
<select name="gender1" id="gender1" >
提交后,这些值将在$ _POST数组中可用。