当前位置: 代码迷 >> Java Web开发 >> checkbox点击事件解决方法
  详细解决方案

checkbox点击事件解决方法

热度:9186   发布时间:2013-02-25 21:14:57.0
checkbox点击事件
HTML code
  <table>  <tr>  <td>    <input name="bay" type="checkbox" value="100">100元月卡  <input name="bay" type="checkbox" value="200">200元季卡  <input name="bay" type="checkbox" value="300">300元半年卡  <input name="bay" type="checkbox" value="400">400年卡  </td>  </tr>    <tr>  <td>    <a href="https://www.abc.com/ok.htm?Email=123@qq.com&sms=123&pay=100&title=付款100元,购买100元月卡" target="_blank">付款</a>  </td>  </tr>  </table>


如何实现选择哪个checkbox,下面的链接中的"pay=100&title=付款100元,购买100元月卡" 就变化

------解决方案--------------------------------------------------------
不熟悉JS的话,很多事情你都做不了啊。。。

简单示意下,自己理解了再修改吧:

HTML code
<script>function changeHref(obj) {  var target = document.getElementById("aPay"); // 查找目标对象  target.href = "https://www.abc.com/ok.htm?pay=" + obj.value; // 修改A标签}</script><table>  <tr>    <td>        <input name="bay" type="checkbox" value="100" onclick="changeHref(this);">100元月卡      <input name="bay" type="checkbox" value="200" onclick="changeHref(this);">200元季卡      <input name="bay" type="checkbox" value="300" onclick="changeHref(this);">300元半年卡      <input name="bay" type="checkbox" value="400" onclick="changeHref(this);">400年卡    </td>  </tr>  <tr>    <td>        <a id="aPay" href="https://www.abc.com/ok.htm?Email=123@qq.com&sms=123&pay=100&title=付款100元,购买100元月卡" target="_blank">付款</a>    </td>  </tr></table>
  相关解决方案