![](/img/trans.png)
[英]JavaScript: how to redirect from “example.com/page1” to “example.com/page2” in same domain?
[英]How to pass form from a page with header as example.com?a=100?
adminhome.php?action=addbook
有一個名為addbook
<form name="addbook" action="adminhome.php?action=addbook" method="get" onsubmit="validatenumber();">
Code:<br/><input type="text" name="code" ><br/>
Class:<br/><input type="number" name="class" id="class1"><br/>
title:<br/><input type="text" name="title"><br/>
price:<br/><input type="number" name="price" id="price"><br/>
quantity:<br/><input type="number" name="quantity" id="quantity"><br/>
category:<br/><input type="text" name="category"><br/>
<input type="submit" value="submit"><br/>
</form>
在下面給出的表單操作屬性中,正確的操作應該是什么?
action="adminhome.php?action=addbook&addbook.php"
實際上,當我提交表單時,它沒有得到驗證。
<script language="javascript">
function validatenumber(){
var class1=document.getElementByName("class")[0];
if(parseInt(class1.value, 10) < 0){
alert("Please enter positive integer");
return false;
}
}
</script>
<form name="addbook" action="adminhome.php" method="get" onsubmit="validatenumber();"> Code:<br/><input type="text" name="code" ><br/> Class:<br/><input type="number" name="class" id="class1"><br/> title:<br/><input type="text" name="title"><br/> price:<br/><input type="number" name="price" id="price"><br/> quantity:<br/><input type="number" name="quantity" id="quantity"><br/> category:<br/><input type="text" name="category"><br/> <input type="hidden" name="action" value="addbook"> <input type="submit" value="submit"><br/> </form>
這將使所有表單輸入和操作在文件adminhome.php中的$ _GET []全局變量中可用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.