2013-03-03 39 views
1

我必须有3个问题。一个带有单选按钮选项,一个带有复选框,另一个带有textarea。我遇到的问题是所有问题都必须与每个问题下面的选择保持一致。我使用了一张表来获取同一行上的问题,但是我遇到的问题是我无法在每个适当的问题下获得选项(单选按钮,复选框和文本区域)。单选按钮,复选框和文本区域

这是我收到:

Your question here: choice 1 choice 2. ques. here: c1, c2, c3, c4 

我需要这样的:

Your question here:  
Choice 1           
Choice 2 

随着其他2个问题在身旁,在格式问题。

这是我使用下面的HTML编码:

<table> 
<tr> 
    <td align="left"> Your question here:</td>  
    <td><input name="choice" type="radio" value="1" />Choice 1 </td> 
    <br /> 
    <td><input name="choice" type="radio" value="2" checked="checked" />Choice 2</td> 

    <td align="center"> Your question here:</td> 
<br> 
    <td><input name="choice" type="checkbox" value="choice1" />Choice 1</td> 
<br>  
    <td><input name="choice" type="checkbox" value="choice2" />Choice 2</td> 
<br>  
    <td><input name="choice" type="checkbox" value="choice3" />Choice 3</td> 
<br>   
    <td><input name="choice" type="checkbox" value="choice4" checked="checked">Choice 4</td> 

<td align="right"> Your question here:</td> 
<td><br /><textarea name="other" rows="5" cols="35"></textarea></td> 


</tr> 
</table>  

我试着用每一个选择,但它彼此下方显示这两个问题和答案直接而这不是我所需要的。这让我发疯,因为我知道这很简单。有人知道如何解决这个问题吗?

+0

你有没有尝试过任何css风格?如果是,请添加此文件。这里没有人给你从零解决方案。在寻求帮助之前,你需要做点什么。 – WooCaSh 2013-03-03 20:41:18

+0

你有什么特别的理由为什么你使用表来实现这个目标? – 2013-03-03 21:18:34

回答

0

那么,我肯定会建议您使用div而不是表格(就我个人而言,我不相信表格是合适的解决方案),据说有三个div,全部左移,宽度各为33%并在其中发布问题和答案。 例如

<div> 
Question 1<br/> 
Choice 1 
Choice 2 
Choice 3 
</div> 

<div> 
Question 2<br/> 
Choice 1 
Choice 2 
Choice 3 
</div> 

<div> 
Question 3<br/> 
Choice 1 
Choice 2 
Choice 3 
</div> 

<style> 
div{ 
    width:33%; 
    float:left; 
} 
</style> 
+0

非常感谢!我甚至没有想过使用div标签。 – user2129596 2013-03-03 20:49:20

0
您的表作为一个解决方案,我认为你需要这个

好...

<table> 
<tr> 
     <td > Your question here:</td> 
     <br /> 
     <td > Your question here:</td> 
     <br /> 
     <td > Your question here:</td> 
</tr> 

<tr> 
    <td> 
     <input name="choice" type="radio" value="1" />Choice 1 
     <br /> 
     <input name="choice" type="radio" value="2" checked="checked" />Choice 2 
    </td> 
    <td> 
     <input name="choice" type="checkbox" value="choice1" />Choice 1 
     <br /> 
     <input name="choice" type="checkbox" value="choice2" />Choice 2 
     <br /> 
     <input name="choice" type="checkbox" value="choice3" />Choice 3 
     <br />  
     <input name="choice" type="checkbox" value="choice4" checked="checked" />Choice 4 
    </td> 
    <td> 
     <textarea name="other" rows="5" cols="25"></textarea> 
    </td> 
</tr> 

</table> 
2

我同意纳德的答案,但回答你的问题时,选择的原因旁边出现的问题出现在旁边,而不是在问题的下面,因为您将它们放置在SAME行内的不同单元格(使用)中(这会生成一个新列)。如果您要制作第二排,并为所有选项设置1个单元格,则它会看起来更像您想要的内容。

<table> 
<tr> 
    <td align="left" style="width:200px;"> Your question here:</td> 
    <td align="center" style="width:200px;"> Your question here:</td> 
    <td align="right" style="width:200px;"> Your question here:</td> 
</tr> 
<tr> 
    <td align="left"> 
     <input name="choice" type="radio" value="1" />Choice 1 <br /> 
     <input name="choice" type="radio" value="2" checked="checked" />Choice 2</td> 

    <td align="center"> 
     <input name="choice" type="checkbox" value="choice1" />Choice 1 <br /> 
     <input name="choice" type="checkbox" value="choice2" />Choice 2 <br/> 
     <input name="choice" type="checkbox" value="choice3" />Choice 3 <br /> 
     <input name="choice" type="checkbox" value="choice4" checked="checked" />Choice  4 
    </td> 

    <td><br /><textarea name="other" rows="5" cols="30"></textarea></td> 
</tr> 
</table> 

我增加了一点造型,使它看起来更有一点间隔。绘制表格的边界以查看事物是如何分开的将是有用的。