四种参数传递的形式——URL,超链接,js,form表单
生活随笔
收集整理的這篇文章主要介紹了
四种参数传递的形式——URL,超链接,js,form表单
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
什么時(shí)候用GET,? 查,刪
什么時(shí)候用POST,增,改? (特列:登陸用Post,因?yàn)椴荒茏層脩裘兔艽a顯示在URL上)
4種get傳參方式
?| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ??<title></title> ??<script type="text/javascript"> ????function Go() { ??????window.location.href="localhost:21811/Handler1.ashx?id=1&name='abc'" ????} ??</script> </head> <body> ?? ??<!--//參數(shù)傳遞的幾種形式--> ??<!--第一種:直接在URL后面加參數(shù):--> ??localhost:21811/Handler1.ashx?id=1&name="abc" ?? ?? ??<!--第二種:用超鏈接的方法傳遞參數(shù):當(dāng)點(diǎn)擊超鏈接的時(shí)候,首先會(huì)跳轉(zhuǎn)到localhost:21811/Handler1.ashx頁(yè)面,然后還會(huì)傳遞id 和name 兩個(gè)參數(shù)過(guò)去--> ??<a href="localhost:21811/Handler1.ashx?id=1&name='abc'">超鏈接傳遞參數(shù)</a></body> ?? ??<!--第三種:通過(guò)js方法傳遞:用戶點(diǎn)擊這個(gè)button按鈕,觸發(fā)onClick事件,執(zhí)行Go()方法,跳轉(zhuǎn)到localhost:21811/Handler1.ashx頁(yè)面,同時(shí)傳遞了id,和name兩個(gè)參數(shù)過(guò)去--> ??<input type="button" onclick="Go()" value="通過(guò)js方法傳遞參數(shù)" /> ?? ???? ??<!--第四種:通過(guò)form表單傳遞--> ??<form action="Handler1.ashx" method="get"><!--注意action里面的連接不能帶參數(shù)的-->> ????<input type="text" name="id" value="3" /> ????<input type="text" name="name" value="abc" /> ????<input type="submit" value="通過(guò)傳遞參數(shù)" /> ??</form> </body> </html> |
總結(jié)
以上是生活随笔為你收集整理的四种参数传递的形式——URL,超链接,js,form表单的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: .net 页面传参方式总结
- 下一篇: struts2框架从数据库批量取得数据集