douzhiji2020 2016-12-15 14:15
浏览 57

表单通过特定按钮提交

Here is my form:

 <form method= "post" action= "edit.php">
    <div class="panel-body">
      <div class="row">

        <div class="col-md-3 col-lg-3 " id= "show"> <img alt="User Pic" src="http://babyinfoforyou.com/wp-content/uploads/2014/10/avatar-300x300.png" class="img-circle img-responsive">
        <a data-original-title="Upload Image" data-toggle="tooltip" type="button" class="btn btn-sm btn-info"><i class="glyphicon glyphicon-edit"></i></a>
         </div>
        <div class=" col-md-9 col-lg-9 "> 
          <table class="table table-user-information">
            <tbody>
              <tr>
                <td>Name:</td>
                <td><span id= "keep"><?php echo $firstname;  ?></span><input id= "change" value= "<?php echo $firstname;  ?>" style= "display:none;" name="name"></td> 
              </tr>
              <tr>
                <td>Date of Birth</td>
                <td><span id= "keep1"><?php echo $birthday; ?></span><input id= "change1" value= "<?php echo $birthday; ?>" style= "display:none;" name="bday"></td>
              </tr>

                 <tr>
                     <tr>
                <td>Gender</td>
                <td><span id= "keep2"><?php echo $gender; ?></span><input id= "change2" value= "<?php echo $gender; ?>" style= "display:none;" name="gen"></td>
              </tr>
                <tr>
                <td>Country</td>
                <td><span id= "keep3">US</span><input id= "change3" value= "US" style= "display:none;" name="country"></td>
              </tr>
              <tr>
                <td>Email</td>
                <td><span id= "keep4"><a href="mailto:info@support.com"><?php echo $email; ?></a></span><input id= "change4" value= "<?php echo $email; ?>" style= "display:none;" name="mail"></td>
              </tr>

            </tbody>
          </table>
        </div>
      </div>
    </div>
         <div class="panel-footer">
                <a data-original-title="Broadcast Message" data-toggle="tooltip" type="button" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-envelope"></i></a>
                <span class="pull-right">
                    <a href="#" data-original-title="Edit this user" data-toggle="tooltip" type="button" class="btn btn-sm btn-warning" onclick = 'showMe()'><i class="glyphicon glyphicon-edit"></i></a>
                    <a data-original-title="Save this user" data-toggle="tooltip" class="btn btn-sm btn-success" type="submit"><i class="glyphicon glyphicon-saved"></i></a>

                </span>
            </div>
    </form>

How can I make only the "save" button go to edit.php not the others? Now when I click on it doesn't go anywhere, Then on edit. php I want it to update and return to this page with the updated version, I'm just stuck on how to get it to go to edit.php

  • 写回答

4条回答 默认 最新

  • douyan2470 2016-12-15 14:16
    关注

    Regarding form submission:

    • An HTML button will submit its parent form if it is type="submit" or has no type attribute (it defaults to submit).

    • An HTML button will not submit its parent form if it is type="button".

    • Since you seem insistent on using an <a> tag rather than an <input> or <button> tag to submit your form, see: Submit form using <a> tag. But this solution is not recommended and is fairly bad practice if there's no reason to not use an <input> or <button> tag, since JavaScript does not work across all browsers, is disabled by default in others, and can always be disabled by users, in all cases rendering your form useless.

    Regarding the rest of your question:

    • Without accompanying PHP it's difficult to know anything about your situation.
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP