小编Ofi*_*uch的帖子

提交表单前更改输入文本值

我正在尝试使用jQuery提交表单之前更改输入文本字段的值,如下所示:

<form actions="http://test.com/" method="GET">
 <input name="test" id="autocompleteform" type="text"/>
</form>
<script>
$('#form-customer-attr-new').submit(function(e) {
    var value = $("#autocompleteform").val();
    value = value.substr(0, value.indexOf(' '));
    if (!isNan(value) && !empty(value)) {
        $("#autocompleteform").val(value);
        alert($("#autocompleteform").val());
        return true;
    } else {
        alert("Invalid Postcode");
        return false;
    }
});
</script>
Run Code Online (Sandbox Code Playgroud)

当我提醒输入文件的值时,它会显示新值,但是当表单提交后,URL中的参数仍然显示输入的旧值,例如:

 old_input_value = "1234 justice spoiler message";
 new_input_value = "1234";
 the_url_after_form_submit_now = "http://test.com?test=1234+justice+spoiler+message";
 the_url_after_form_submit_should_be ="http://test.com?test=1234";
Run Code Online (Sandbox Code Playgroud)

javascript php forms jquery textinput

5
推荐指数
1
解决办法
5312
查看次数

MySQL 同时使用 ORDER BY 和 GROUP BY

我有一个包含 id 价格类别等产品的表格......我试图从每个 item_category 中提取 1 个项目,这是最新的一个(在其自己的类别中具有最高的 ID)。

这是代码,它从 6 个类别中获取 6 个项目,但它们是最旧的(ID 最小)

    SELECT * from items WHERE item_category = '2' or item_category = '4' or 
item_category = '12' or item_category = '13' or item_category = '14' or 
item_category = '19' GROUP BY `item_category`  ORDER BY `item_id`  LIMIT 6
Run Code Online (Sandbox Code Playgroud)

Order by ID 在返回的 6 个项目的数组上执行,而不在原始表上执行。

我该如何提取最新的项目?

我认为最好的查询

select *
from items
where item_category in ("2","4","12","13","14","19")
group by item_category
order by item_category DESC
Run Code Online (Sandbox Code Playgroud)

php mysql

4
推荐指数
1
解决办法
6068
查看次数

MySQL错误 - 插入表中

我在插入表时有一点问题,这里是代码:

mysql_query("INSERT INTO admin_menu (id, title, type, icon, parent, url, order, append, module) VALUES('', 'powerpoint', '0', 'powerpoint.png', '0', 'powerpoint/config', '0', '0', '0' ) ") or die(mysql_error()); 
Run Code Online (Sandbox Code Playgroud)

它给了我以下错误:

您的SQL语法有错误; 查看与您的MySQL服务器版本相对应的手册,以便在"order,append,module"附近使用正确的语法VALUES('','powerpoint','0','powerpoint.png','0','pow'在第1行

任何帮助将不胜感激,谢谢!

php mysql insert

1
推荐指数
1
解决办法
455
查看次数

标签 统计

php ×3

mysql ×2

forms ×1

insert ×1

javascript ×1

jquery ×1

textinput ×1