gpt4 book ai didi

javascript - 如果使用 javascript 选中复选框,如何重定向到特定链接?

转载 作者:太空宇宙 更新时间:2023-11-04 13:39:40 25 4
gpt4 key购买 nike

如果使用 javascript 选中复选框,如何重定向到特定链接?

我正在这样做,但它不适合我..

<input type="checkbox" name="yousendit" id="yousendit" value="1" onselect="return yousendit();"/>

<script type=javascript>
function yousendit()
{
if(document.getElementById('yousendit').checked== "checked")
{
window.location='https://www.yousendit.com/dropbox?dropbox=mydomain';
return false;
}
return true;

}
</script>

请帮忙

最佳答案

您的来源存在一些问题。这是工作版本:

<input type="checkbox" name="yousendit" id="yousendit" value="1" onclick="return yousendit();"/>
<script>
function yousendit(){
if(document.getElementById('yousendit').checked){
window.location='https://www.yousendit.com/dropbox?dropbox=mydomain';
return false;
}
return true;

}
</script>

变化:

  • onclick 而不是 onselect
  • 复选框的 checked 属性是 bool 值

关于javascript - 如果使用 javascript 选中复选框,如何重定向到特定链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3690419/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com