0

我完成了用户输入信息并从下拉列表中选择的搜索页面。我还添加了按钮 AddList,您可以在其中拥有多个更改标签名称的搜索表单。所有搜索最终都将在一个提交按钮中执行,每个搜索将在一个查询中进行。我的表包含所有信息,元组只包含数字。

更新:我尝试更改输入标签的输入类型,但启用和禁用功能似乎不适用于整数,仅适用于文本字段。我该如何解决?

我的提交是明天,这是我的搜索代码:

 <script type="text/javascript">

            $('#exactButton').live('click', function(){
                $(this).prev().prev().prev().prev().prev().removeAttr('disabled');

                $(this).prev().prev().prev().attr('disabled',true);
                $(this).prev().prev().prev().prev().attr('disabled',true); 
            });

            $('#rangeButton').live('click',function(){
                $(this).prev().prev().removeAttr('disabled');
                $(this).prev().prev().prev().removeAttr('disabled');

                $(this).prev().prev().prev().prev().attr('disabled',true);
            });

        })
    </script>

这是我的 HTML 代码:

 <button id="button">Add List</button><br><br>
        <form id ="form" name="search" method="get" action="test.php">
            <div id="div">
                <select name ="select" >
                    ...options...
                </select>

                Value:<input type="text" name="exact" id="exactField" />

                From: <input type="text" name="from" id="fromField" />
                To: <input type="text" name="to" id="toField" />

                <br>
                <input type="button" name="answer" value="Range" id="rangeButton" />
                <input type="button" name="answer" value="Exact" id="exactButton" />

            </div>
            <br>
            <input type="submit"name="search" value="Submit">
        </form>

先感谢您..

4

4 回答 4

0

正如 Dagon 所说,您将在 URL 中看到所有提交的参数,因为您正在使用 method 提交表单GET。这是很好的解释:http ://www.w3schools.com/php/php_get.asp

于 2013-01-14T19:21:46.657 回答
0

一个想法:为元素添加一些自定义属性(也添加到克隆中)。

this.attr("mycustomattribute","somevalue");

在此之后,您可以使用自定义属性和值获取页面上的所有元素。

divs = $('div[mycustomattribute="somevalue"]'); //should give all div container with attribute "mycustomattribute" with value "somevalue" 
divs.each(function(){ 
   console.log(this,$(this).attr('name'));//show expression (for debug)
});

然后您可以收集这些元素,将其序列化并将其添加到您的帖子中。未测试,但一个想法。

亲切的问候

于 2013-01-14T19:29:59.660 回答
0

在 PHP 中,它已经存在。

print_r($_GET);将列出 GET 方法发送的所有参数

print_r($_POST);将列出所有通过 POST 方法发送的参数。

然后,当然,您需要在数组中进行迭代以将每个值包含在查询语句中。

于 2013-01-14T19:50:14.813 回答
0

您可以使用前缀或后缀命名输入,对应于用户单击以添加列表并将这些输入集添加到仅表单的序列。

<form id ="form" name="search" method="get" action="test.php">
    <div>
            <select name ="select[1]" >
                ...options...
            </select>

            Value:<input type="text" name="exact[1]" class="exactField" />

            From: <input type="text" name="from[1]" class="fromField" />
            To: <input type="text" name="to[1]" class="toField" />

            <br>
            <input type="button" name="answer[1]" value="Range" class="rangeButton" />
            <input type="button" name="answer[1]" value="Exact" class="exactButton" />

        </div>
    <div>
            <select name ="select[2]" >
                ...options...
            </select>

            Value:<input type="text" name="exact[2]" class="exactField" />

            From: <input type="text" name="from[2]" class="fromField" />
            To: <input type="text" name="to[2]" class="toField" />

            <br>
            <input type="button" name="answer[2]" value="Range" class="rangeButton" />
            <input type="button" name="answer[2]" value="Exact" class="exactButton" />

        </div>
.
.
.
        <br>
        <input type="submit"name="search" value="Submit">
</form>
于 2013-01-16T05:12:57.870 回答