【发布时间】:2013-10-15 11:00:48
【问题描述】:
我有一些包含两个单选按钮的 HTML。根据选择的单选按钮,我想下载两个文件之一。我该怎么做?
这是我迄今为止尝试过的:
<head>
<script type="text/javascript">
function downloadAddin(){
document.getElementById("bit32");
if (document.getElementById("bit32").checked) {
document.location.href="ECSSetup32.exe";
} else {
document.location.href="ECSSetup64.exe";
}
}
</script>
</head>
<form>
<p><input type="radio" id="bit32" name="arch" checked>Windows 32-bit
<br><input type="radio" id="bit64" name="arch">Windows 64-bit
<p>
<button type="submit" onclick="downloadAddin()"id="download_button"
style="background-color: #0078FF; padding: 1%; color: #ffffff; border:1px
solid; border-radius:10px; font-size:75%">Accept and Download</button>
</form>
我希望用户能够选择一个单选按钮,按“同意并下载”按钮,然后获取他们请求的两个 .exe 文件之一。有什么想法吗?
【问题讨论】:
-
仅供参考,如果您不展示您已尝试过的内容并询问您遇到的特定问题,您的问题将会受到否定。
-
@Nick 刚刚说了什么。再说一次,寻找这样的东西:fiddle ?
-
好的,我已经更新了问题;抱歉,如果不清楚。
-
我刚刚注意到一些驴子以-4 票将我的帖子搞砸了。如果我很快没有看到任何回复,我会重新发布。
-
@akinuri 谢谢,这正是我需要的!我怎样才能给你功劳呢?
标签: javascript html radio-button