作为一个小技巧,暂时归类到ASP中。
在设计网站的时,我们可能会想把链接做成按钮的样子,按钮做成链接的样子。下面说一下我的方法。 1、按钮做成链接(图片)的样子 提交按钮<input type="submit" value="提交"> 提交链接<a href="#" onclick="表单名字.submit()">提交</a>
重置按钮<input type="reset" value="重置"> 重置链接<a href="#" onclick="表单名字.reset()">重置</a>
普通按钮<input type="button" value="按钮" onclick="函数()"> 普通链接<a href="#" onclick="函数()">链接</a>
至于图片也一样把a标签换成img
2、链接做成按钮的样子 <a href="reg.asp">注册</a> =><input type="button" value="注册" onclick="location.href='reg.asp'">
----------------------------------- 有的时候我们完全可以手工做一个get方式的表单,至于用按钮还是链接随心所欲。 <form action="xx.asp" method="get" name="form1"> <input name="aa" type="text" id="aa"> <input name="bb" type="text" id="bb"> <input type="submit" name="Submit" value="提交"> </form> => <input name="aa" type="text" id="aa"> <input name="bb" type="text" id="bb"> <input type="button" value="按钮" onclick="location.href='xx.asp?aa='+document.all['aa'].value+'&bb='+document.all['bb'].value"> ----------------------------------- 进一步说我们还可以做一个按钮(链接)来同时传递js变量,表单input的值,asp变量,Recordset值 <script language="javascript"> var id1=1; </script> <% id3=3 .... rs.open exec,conn,1,1 假设有rs("id4")=4 ... %> <input name="id2" type="text" id="id2" value="2"> <input type="button" value="按钮" onclick="location.href='xx.asp?id1='+id1+'&id2='+document.all['id2'].value+'&id3=<%=id3%>&id4=<%=rs("id4")%>'"> 我们按下按钮会看到浏览器的url是xx.asp?id1=1&id2=2&id3=3&id4=4 在xx.asp中我们就可以用request.querystring来得到所有变量,这样是不是变相的客户端js和服务器段的变量传递?
|