有没有一种方法可以一次只选中1个HTML单选按钮?

时间:2020-09-27 13:13:44

标签: php html

我已经在Stack Overflow上看到其他人问同样的问题,但是答案仍然是相同的:“使用name属性。” 这对我不起作用,这是我的代码:

<form action="index.php">
    <input type="radio" name="1">
    <input type="radio" name="2">
</form>

我做错了吗?

2 个答案:

答案 0 :(得分:0)

with open('line_number.txt', 'rb') as inp:
line = inp.read()

fp = open("list.txt")

for i, line in enumerate(fp):
    if i == line - 1: #iterates until the number match 

        s = i + 1

        with open('new.txt', 'w') as outp:
            outp.write(s)
        outp.close()

        print(i)

    break
fp.close()

答案 1 :(得分:-1)

两个按钮的名称相同:

<form action="index.php">
    <input type="radio" name="one">
    <input type="radio" name="one">
</form>
相关问题