HTML表单提交无效

时间:2016-01-11 05:17:35

标签: html forms submit form-submit

我创建了一个html ctuff,它有一个表单sumbission。 html正确执行,但问题是表单提交无效。

我的代码如下:

任何人都可以告诉我一些解决方案吗

JSFiddle

<form method="get" name="search" action="/myaction">
  <ul class="nav pull-right search-options"
      style="margin-bottom: 0px; margin-top: 7px; !important">
      <li>      
        <div class="input-box" style="height: 30px;">

          <input class="search-box" id="typeahead" data-provide="typeahead" data-items="4" autocomplete="off" data-source='["apple", "animal"]' name="query" placeholder="Search..." type="text" style="margin-bottom: 0px; width: 8em !important;" />
        </div>
      </li>
      <li class="dropdown user" style="line-height: 0px !important;">
        <div class="btn-group" style="margin-top: 0px">
          <a href="javascript:void(0);" class="dropdown-toggle search" data-toggle="dropdown" data-close-others="true" style="padding-top: 0px; padding-left: 0px; padding-bottom: 0px; padding-right: 0px;">
            <button class="btn search-option" style="height: 30px; padding-top: 5px; margin-top: 0px; width: 8em !important">
              <span class="search-selection">Test</span> <span class="caret"></span>
            </button>
          </a>
          <ul class="dropdown-menu dropdown-menus" style="min-width: inherit;">
            <li><a href="javascript:void(0);" style="padding-right: 13px;">Test1</a></li>
            <li><a href="javascript:void(0);" style="padding-right: 13px;">Test2</a></li>
            <li><a href="javascript:void(0);" style="padding-right: 13px;">Test3</a></li>
            <li><a href="javascript:void(0);" style="padding-right: 13px;">Test4</a></li>
          </ul>
        </div>
      </li>

      <li class="search-button" style="line-height: 0px !important;">
        <div class="btn-group" style="margin-top: 0px">
          <button type="submit" class="btn blue" data-toggle="dropdown" style="padding-top: 5px; padding-bottom: 5px;"> <span class="icon-search"></span>Submit</button>
        </div>
      </li>
    </ul>
  </form> 

4 个答案:

答案 0 :(得分:0)

不确定,因为我无法看到php页面但是你的动作地址缺少一个点。

答案 1 :(得分:0)

您的表单操作没有有效路径将其引用到包含服务器端代码的文件

答案 2 :(得分:0)

试试这个:

<form method="get" action="./myaction.php">
      <ul class="nav pull-right search-options"
          style="margin-bottom: 0px; margin-top: 7px; !important">
          <li>      
            <div class="input-box" style="height: 30px;">

              <input class="search-box" id="typeahead" data-provide="typeahead" data-items="4" autocomplete="off" data-source='["apple", "animal"]' name="query" placeholder="Search..." type="text" style="margin-bottom: 0px; width: 8em !important;" />
            </div>
          </li>
          <li class="dropdown user" style="line-height: 0px !important;">
            <div class="btn-group" style="margin-top: 0px">
              <a href="javascript:void(0);" class="dropdown-toggle search" data-toggle="dropdown" data-close-others="true" style="padding-top: 0px; padding-left: 0px; padding-bottom: 0px; padding-right: 0px;">
                <button class="btn search-option" style="height: 30px; padding-top: 5px; margin-top: 0px; width: 8em !important">
                  <span class="search-selection">Test</span> <span class="caret"></span>
                </button>
              </a>
              <ul class="dropdown-menu dropdown-menus" style="min-width: inherit;">
                <li><a href="javascript:void(0);" style="padding-right: 13px;">Test1</a></li>
                <li><a href="javascript:void(0);" style="padding-right: 13px;">Test2</a></li>
                <li><a href="javascript:void(0);" style="padding-right: 13px;">Test3</a></li>
                <li><a href="javascript:void(0);" style="padding-right: 13px;">Test4</a></li>
              </ul>
            </div>
          </li>

          <li class="search-button" style="line-height: 0px !important;">
            <div class="btn-group" style="margin-top: 0px">
              <button type="submit" class="btn blue" data-toggle="dropdown" style="padding-top: 5px; padding-bottom: 5px;"> <span class="icon-search"></span>Submit</button>
            </div>
          </li>
        </ul>
      </form>

答案 3 :(得分:0)

If you want to check why it is not working
please follow this steps.

Pass full url OR leave blank for same page action.

If you want to check in same page
1) give name to submit button
<button type="submit" name="submit-button" class="btn blue" data-toggle="dropdown" style="padding-top: 5px; padding-bottom: 5px;"> <span class="icon-search"></span>Submit</button>
2) Write this code before start html tag


<?php
if(isset($_GET["submit-button"]))
{
echo "Success";
}

?>