按钮链接乾坤大挪移

作者:未知 来源:未知 添加时间:2004年4月9日 字体:

作为一个小技巧,暂时归类到ASP中。

在设计网站的时,我们可能会想把链接做成按钮的样子,按钮做成链接的样子。下面说一下我的方法。

  1、按钮做成链接(图片)的样子

  提交按钮<input type="submit" &#118alue="提交">

  提交链接<a href="#" &#111nclick="表单名字.submit()">提交</a>


重置按钮<input type="reset" &#118alue="重置">

  重置链接<a href="#" &#111nclick="表单名字.reset()">重置</a>


普通按钮<input type="button" &#118alue="按钮" &#111nclick="函数()">

  普通链接<a href="#" &#111nclick="函数()">链接</a>


至于图片也一样把a标签换成img


2、链接做成按钮的样子 

  <a href="reg.asp">注册</a>

  =><input type="button" &#118alue="注册" &#111nclick="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" &#118alue="提交">

  </form>

  =>

  <input name="aa" type="text" id="aa">

  <input name="bb" type="text" id="bb">

  <input type="button" &#118alue="按钮" &#111nclick="location.href='xx.asp?aa='+document.all['aa'].&#118alue+'&bb='+document.all['bb'].&#118alue">

  -----------------------------------

  进一步说我们还可以做一个按钮(链接)来同时传递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" &#118alue="2">

  <input type="button" &#118alue="按钮" 

  &#111nclick="location.href='xx.asp?id1='+id1+'&id2='+document.all['id2'].&#118alue+'&id3=<%=id3%>&id4=<%=rs("id4")%>'">

  我们按下按钮会看到浏览器的url是xx.asp?id1=1&id2=2&id3=3&id4=4

  在xx.asp中我们就可以用request.querystring来得到所有变量,这样是不是变相的客户端js和服务器段的变量传递?



ppdesk