我的表单单选按钮不起作用

发布于 2024-08-29 04:56:51 字数 164 浏览 4 评论 0原文

一些简单的 HTMl,我添加了样式样式,我应该使用标签吗?它的意思是一次只允许选择一个。我做错了什么?我是代码盲:P

JSfiddle 这里。

谢谢。

Some simple HTMl, I've added spans for styling, should I be using labels instead? It's meant to only allow one selected at a time. What am I doing wrong? I am codeblind :P

JSfiddle here.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

原野 2024-09-05 04:56:51

单选按钮组是由多个同名单选按钮创建的。

您有许多单选按钮组,每个组都包含一个按钮。

您不应为样式添加标签,但应该添加标签以将单选按钮的标签与单选按钮关联起来。

A radio group is created by a having a number of radio buttons with the same name.

You have a number of radio groups, each containing one button.

You shouldn't add labels for styling, but you should add labels for associating the label of a radio button with the radio button.

南城旧梦 2024-09-05 04:56:51

您需要将单选按钮分组如下:

<form>
    <span id="betalfakturavalg">
        <input type="radio" name="group1" title="Valg Faktura"
        onclick="document.getElementById('betalfakturavalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Faktura - For bedrifter  
    </span>
    <br>
    <span id="betalkortvalg">
        <input type="radio" name="group1" title="Valg Kreditkort"
        onclick="document.getElementById('betalkortvalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Kreditkort - For alle privatpersoner
    </span>
</form>

you need to group the radio buttons as such:

<form>
    <span id="betalfakturavalg">
        <input type="radio" name="group1" title="Valg Faktura"
        onclick="document.getElementById('betalfakturavalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Faktura - For bedrifter  
    </span>
    <br>
    <span id="betalkortvalg">
        <input type="radio" name="group1" title="Valg Kreditkort"
        onclick="document.getElementById('betalkortvalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Kreditkort - For alle privatpersoner
    </span>
</form>
情独悲 2024-09-05 04:56:51

在单选按钮中使用单个名称,

<form>
    <span id="betalfakturavalg">
        <input type="radio" name="betalfakturavalg" title="Valg Faktura"
        onclick="document.getElementById('betalfakturavalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Faktura - For bedrifter  
    </span>
    <br>
    <span id="betalkortvalg">
        <input type="radio" name="betalfakturavalg" title="Valg Kreditkort"
        onclick="document.getElementById('betalkortvalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Kreditkort - For alle privatpersoner
    </span>
</form>

Use single name in the radio button,

<form>
    <span id="betalfakturavalg">
        <input type="radio" name="betalfakturavalg" title="Valg Faktura"
        onclick="document.getElementById('betalfakturavalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Faktura - For bedrifter  
    </span>
    <br>
    <span id="betalkortvalg">
        <input type="radio" name="betalfakturavalg" title="Valg Kreditkort"
        onclick="document.getElementById('betalkortvalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Kreditkort - For alle privatpersoner
    </span>
</form>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文