简体   繁体   English

用html提交表格

[英]submit a form in html

I want to submit a form with two components: two dropdown lists. 我想提交一个包含两个部分的表单:两个下拉列表。 Only the first form 'School' and the submit button itself are submitted. 仅提交第一个表单“学校”和提交按钮本身。 The second form 'pool' is gone somehow. 第二种形式的“池”以某种方式消失了。

<form method='get'>
    <select name='School'>
        <option>School Name</option>
        <?php while ($row = sqlsrv_fetch_object($result)){?>
        <option value= "<?php echo $row->ClientID ?>" > <?php echo $row->ClientName; ?></option>
        <?php } ?>
    </select>

    <div id='result'>
    <select name='pool1[]' id="pool" multiple="multiple">        
        <option value='de'>de</option>
    </select>
    <input type="button" value="Delete" name="submit2" onclick="removeOption();"/>
    </div>                      

    <div id="teacherdiv">
    <select name="Teacher[]">
        <option>Select Teacher First</option>            
    </select>                    
    </div>
    <input type="submit" value="Add" name="submit"/>                        

    </form>

This is the URL that I got after I pressed the submit button: 这是我按下提交按钮后获得的URL:

SchoolName.php?School=7&Teacher%5B%5D=Select+Teacher+First&submit=Add SchoolName.php?School = 7&Teacher%5B%5D = Select + Teacher + First&submit =添加

The pool1 dropdown list is not in there. pool1下拉列表不在其中。

Have the first option selected by default to ensure a value is passed. 默认情况下,选择第一个选项以确保传递值。

Otherwise it will not even pass an empty value. 否则,它甚至不会传递空值。

    <select name='pool1[]' id="pool" multiple="multiple">        
        <option value='de' selected="selected">de</option>
    </select>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM