Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检测触发表单提交的内容_Javascript_Php_Jquery_Html_Forms - Fatal编程技术网

Javascript 检测触发表单提交的内容

Javascript 检测触发表单提交的内容,javascript,php,jquery,html,forms,Javascript,Php,Jquery,Html,Forms,我正在尝试遍历并修改其他人的代码(racktables开源应用程序)。。。也许我已经看得太久了。 但我不明白为什么点击下面第四个单元格中的“编辑行”图像/按钮会触发表单提交 HTML代码 <tr> <td id=""><img src="?module=chrome&amp;uri=pix/tango-user-trash-16x16-gray.png" title="1 rack(s) here" height

我正在尝试遍历并修改其他人的代码(racktables开源应用程序)。。。也许我已经看得太久了。
但我不明白为什么点击下面第四个单元格中的“编辑行”图像/按钮会触发表单提交

HTML代码

          <tr>
             <td id=""><img src="?module=chrome&amp;uri=pix/tango-user-trash-16x16-gray.png" title="1 rack(s) here" height="16" width="16" border="0">
                  <form method="post" id="updateRow" name="updateRow" action="?module=redirect&amp;page=rackspace&amp;tab=editrows&amp;op=updateRow">
                     <input tabindex="1" name="row_id" value="26270" type="hidden">
                 </form>
              </td>
             <td><div id="location_name"></div></td>
             <td><div id="row_name">BLDG5:First Floor</div></td>
             <td>
                 <input tabindex="1" name="edit" class="edit" src="?module=chrome&amp;uri=pix/pencil-icon.png" id="" title="Edit row" type="image" border="0">&nbsp;
                 <input tabindex="1" style="display: none;" name="submit" class="icon" src="?module=chrome&amp;uri=pix/tango-document-save-16x16.png" title="Save changes" type="image" border="0"></td>
             <td><a href="index.php?page=row&amp;row_id=26270">Row BLDG5:First Floor</a></td>
          </tr>
    //edit button handler   
    $(".edit").click(function(e){
            var location_id = this.id;
            var menu = $( "#location_id" ).clone();
            //locate the associated "location_name" field for the selected row & hide the column    
            var location_name=$(this).parent().siblings().children("#location_name").hide();
            var row_name = $(this).parent().siblings().children("#row_name").hide();
            //replace location_name with the new menu
            $(location_name).replaceWith(menu);
            menu.find('option').each(function(i, opt) {
                    // when the value is found, set the 'selected' attribute
                    if($(opt).attr('value') == location_id.toString()) $(opt).attr('selected', 'selected');
            });

            //change row name to input box for editing
            var input = $(document.createElement('input'));
            $(input).attr('type','text');
            //$(input).attr('name','edit_row_name');
            $(input).attr('value', $(row_name).text());

            //replace exiting row_name with this new input box. 
            $(row_name).replaceWith($(input));
            //show save button
            var save_btn = $(this).siblings(".icon").show();
    });
我到目前为止所做的尝试

当我在PHP中禁用/注释掉创建表单的逻辑时,edit按钮按我希望的方式工作

我一直在对文件夹结构进行灰显,以查看是否有一些javascript嵌入到我没有看到的地方。但是没有什么东西冲着我跳。
这可能是我没有看到/认识到的非常简单的事情

有什么建议吗?

请参阅:

<input type='image' />  

基本上是一个图形化的提交按钮。因此,除非您取消单击处理程序中的默认操作(
e.preventDefault()
),否则它应该提交其包含表单。您确定
input type=“image”
存在吗?@nnnn我没有意识到这一点。我以为只有“提交”类型才会触发。哇!我得多读点书。谢谢你@是的,是的。HTML5之前就有HTML,尽管我不喜欢引用这个网站,但你应该看看下面的列表
$(".edit").click(function(e){
    e.preventDefault(); // <----use this.