donglu5728 2012-07-20 07:35
浏览 20
已采纳

HTML - 形成最佳实践

It's OK to have a form with more submit buttons? I mean I have a form which contains some input fields and a table and 3 buttons which will export some information in different formats

<form id="form1" name="form1" method="post" >
    <label for="country"><strong>Countries: </strong></label><br />
    <select id="country" name="country">
      <?php
      //some php code here
      ?>
    </select> 
    <br />
    <br/>
    <label for="start_date"><strong>Start date: </strong></label><br />
    <input name="start_date" type="text" id="start_date" value="<?php if(!empty($start))echo $start; ?>" size="20" />
    <br />
    <br />  
    <label for="stop_date"><strong>Stop date: </strong></label><br />
    <input name="stop_date" type="text" id="stop_date" value="<?php if(!empty($stop)) echo $stop; ?>" size="20" />
    <br />
    <br />
        <input type="submit" name="fill_table" value="Retrieve data" /> 

    <div id="table">
      <h1>&nbsp;</h1>
      <hr />
      <h2>Sales Report</h2>
        <table class="display" id="data_table" >
          <thead>
              <tr>
                <th>Product</th>
                <th>Date</th>
                <th>Quantity</th>
              </tr>
          </thead>
          <tbody>
            <?php
                //some php code here
            ?>
          </tbody>
        </table>
        <br />
        <br />
        <br />
        <input type="submit" class="button" name="export_xls" value="Export xls" />
        <input style="margin-left:10px;" type="submit" name="export_html" value="Export html" />
  </form>

Is it ok to do it this way or should i make 3 forms each one having a particular submit button? Each time i press a submit button I'm intrested in the input fields :start_date, stop_date and the selected item from "country". P.S. I want to know if it's optimal and how other programmers would handle this stuff

  • 写回答

4条回答 默认 最新

  • drwkqwa82140 2012-07-20 07:42
    关注

    I don't think it's a bad idea. But all your submit buttons must have the same name attribute.

    Check out this

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么