English 中文(简体)
展示案文以选择相应的无线电台
原标题:Clicking the text to select corresponding radio button

I m 采用PHP创建静态网络应用。 每一个问题都包含一个单独的<代码><label>,并且有四种可能的选择,使用radio buttons使用户能够选择自己的回答。 目前的超文本处理单一问题如下:

<label for="349">What is my middle name?</label>
<br>
<input id="349" type="radio" value="1" name="349">Abe
<br>
<input id="349" type="radio" value="2" name="349">Andrew
<br>
<input id="349" type="radio" value="3" name="349">Andre
<br>
<input id="349" type="radio" value="4" name="349">Anderson
<br>

我希望用户选择点击与无线电台有关的文本。 现在,用户只能点击无线电塔顿本身,我认为这是一个相当麻烦的任务。

页: 1 无法通过点击选择文本和标注如下的建议点选择特定无线电台:标的对应符号<>。 我已经这样做,而且我仍然不工作。

My question is: I d like to be able to click the text of an <input type="radio"> object, as opposed to only being able to select the radio button itself. I know I ve read about this before but can t seem to find any solution to my problem. Any help or suggestions are much appreciated!

最佳回答

In your code, you ve got a label on the form itself. You want to put labels on each individual radio group, as shown below.

<form>
  <p>What is my middle name?</p>
  <br>
  <input id="349" type="radio" value="1" name="question1">
  <label for="349">Abe</label>
  <br>
  <input id="350" type="radio" value="2" name="question1">
  <label for="350">Andrew</label>
  <br>
  <input id="351" type="radio" value="3" name="question1">
  <label for="351">Andre</label>
  <br>
  <input id="352" type="radio" value="4" name="question1">
  <label for="352">Anderson</label>
  <br>
</form>

你们应当牢记,两个因素永远不应有同样的身份证明。 <代码> 姓名/代码>属性,以便无线电台能够作为一个集团运作,只允许在某个时间进行单一选择。

问题回答

如果按照Nathan的回答,那么在无线电台和标签之间似乎存在着一些不可动摇的空间。 在这里,如何使其无缝地加入(见,这一条):

<form>
    <p>What is my middle name?</p>
    <br>
    <label><input id="349" type="radio" value="1" name="question1">Abe</label>
    <br>
    <label><input id="350" type="radio" value="2" name="question1">Andrew</label>
    <br>
    <label><input id="351" type="radio" value="3" name="question1">Andre</label>
    <br>
    <label><input id="352" type="radio" value="4" name="question1">Anderson</label>
    <br>
</form>

标签应围绕每个答案,例如,在Abe、Andrew等周围。

我多年来一直在这样做,但利用变量对我来说,这些工作都没有。

    echo "<input type= radio  name= student  id= $studentID  value= $studentID >
        <label for= $studentID >$fname</label> $lname<br />
";
    echo "<input type= radio  name= student  id= $studentID  value= $studentID >
        <label for= $studentID >$fname $lname</label><br />
";

来源:

        <input type= radio  name= student  id= 986875  value= 986875 >
        <label for= 986875 >John</label> Brown<br />

你可以这样做。

 <label for="1">hi</label>
 <input type="radio" id="1" />

So if you click on the text or label it selects the radio button. But if you do this...

<label for="1">//</label>

并且,如果你点上第2个标签,那么我刚才所写的守则也将选择该电台。

在标签栏内 Nest取投入标记可确保标签在无线电台旁边。 根据先前的建议,你可以在html档案中把标签贴在任何地方,并在点击时选择相关的无线电台。 具体如下:

<html>
<body>

<form>
  <p>What is my middle name?</p>
  <br>
  <input id="349" type="radio" value="1" name="question1">

  <br>
  <input id="350" type="radio" value="2" name="question1">
  <label for="350">Andrew</label>
  <br>
  <input id="351" type="radio" value="3" name="question1">

  <br>
  <input id="352" type="radio" value="4" name="question1">
  <label for="352">Anderson</label>
  <br>
</form><br/>
<p>This is a paragraph</p>
  <label for="349">Abe</label><br/>
  <label for="351">Andre</label>
  
</body>
</html>

消除这种缺陷:

<form>
  <p>What is my middle name?</p>
  <br>
  
  <label>
    <input id="349" type="radio" value="1" name="question1"/>Abe
  </label>
  <br>
  
  <label>
    <input id="350" type="radio" value="2" name="question1"/>Andrew
  </label>
  <br>
  
  <label>
    <input id="351" type="radio" value="3" name="question1"/>Andre
  </label>
  <br>
  
  <label>
    <input id="352" type="radio" value="4" name="question1"/>Anderson
  </label>
  <br>
</form>

∗∗∗∗ a 难以编码一切的良好想法。

页: 1

对于无线电台或检查箱,你需要使用property binding。 例如:

In the .ts file:

colors = [ Red ,  Orange ,  Yellow ,  Green ,  Blue ,  Indigo ,  Violet ];

在html的档案中,<<>/strong>和id” 输入右边<>ngFor表述(见color>)和相同数值。 <><>for> and the id> need to be listed below strong>[ ]:

<div class="radio" *ngFor="let color of colors">
    <label [for]="color">
        <input type="radio" name="color" [id]="color" ngModel [value]="color">
        {{color}}
    </label>
</div>

然后,你可以选择贴标签。

Result: enter image description here





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签