我有一个带有字段的表单,允许用户更改页面上的结果数量,计划是提交表单以在更改页面大小时更新结果。
<form id="js-selectionForm" class="simple_form" method="get" action="/knowledge/contaminants.php">
<div class="pad-5">
...
</div>
<div class="pad-5">
...
</div>
<div class="pad-5">
...
</div>
<div class="pad-5">
...
</div>
<div class="pad-5">
<input class="button pad-2" id="submit" type="submit" name="submit" value="Search"/>
<h3 class="text-purple inline-block margin-10-left">
Please select search criteria above </h3>
<label class="right">Page size:
<input class="refreshPage" type="number" name="pageSize" min="1" max="100"
title="The number of results per page - 1 to 100"
value="25"/>
</label>
</div>
我的jQuery包括以下内容;
$('.refreshPage').change(function () {
$("#js-selectionForm").submit();
});
我知道这个选择有效,因为我已经输入了console.log语句来检查,但表单从未提交过。我之前使用过类似的代码而且它一直有效,所以我必须在这里做错事,有人能帮助我发现我的错误吗?
答案 0 :(得分:0)
您不一定需要import { Sim } from 'ionic-native';
Sim.getSimInfo().then(
(info) => console.log('Sim info: ', info),
(err) => console.log('Unable to get sim info: ', err)
);
Sim.hasReadPermission().then(
(info) => console.log('Has permission:', info)
);
Sim.requestReadPermission().then(
() => console.log('Permission granted'),
() => console.log('Permission denied')
);
;见:
.submit()
PS - 你最后错过了$('.refreshPage').change(function () {
$("#submit").click();
});
。这可能是它无法正常工作的原因。你的代码对我来说似乎是正确的。
答案 1 :(得分:0)
根据@ Ivar的建议,更改提交输入的name
和id
$('.refreshPage').change(function () {
$("#js-selectionForm").submit();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="js-selectionForm" class="simple_form" method="get" action="/knowledge/contaminants.php">
<div class="pad-5">
<input class="button pad-2" id="submitMe" type="submit" name="submitMe" value="Search" />
<h3 class="text-purple inline-block margin-10-left">
Please select search criteria above </h3>
<label class="right">Page size:
<input class="refreshPage" type="number" name="pageSize" min="1" max="100"
title="The number of results per page - 1 to 100"
value="25" />
</label>
</div>
</form>