如何在循环中默认无线电值?

时间:2014-10-03 20:31:32

标签: javascript coldfusion

我有一个循环查询,我想要做的是显示 每个无线电值的“评级”值。

倾倒值GET(5,4.5,5,5) 因此,我希望在单选按钮中默认使用每个值。

我做了http://jsfiddle.net/yb9mxxu5/1/

如何使用下表

完成此操作
<table>
<thead>
    <tr><th>1</th><th>2</th><th>3</th><th>4</th><th>question</th></tr>
</thead>
<tbody>
<cfloop index="i" from="1" to="4">
    <cfset rating = Mush2["rating" & i][Mush2.CurrentRow]>
    <cfset question = Mush2["csedept_question" & i][Mush2.CurrentRow]>
    <tr>
        <cfdump var=#rating#>
        <td valign="top">
            <input type="radio" name="rating1#i#row#CurrentRow#" value="5">
        </td>
        <td valign="top">
            <input type="radio" name="rating2#i#row#CurrentRow#" value="4.5">
        </td>
        <td valign="top"><div align="center">   
            <input type="radio" name="rating3#i#row#CurrentRow#" value="4">
        </td>
        <td valign="top">
            <input type="radio" name="rating4#i#row#CurrentRow#" value="3.5">
        </td>
        <cfif i is 1>
           <td><strong>testing </strong><br/>
               <span class="description">test</span>
           </td>
        </cfif>
        <cfif i is 2>
            <td><strong>testing</strong><br/>
                <span class="description">test</span>
            </td>
        </cfif>
        <cfif i is 3>
            <td><strong>testing</strong><br/>
                <span class="description">test</span>
            </td>
        </cfif>
        <cfif i is 4>
            <td><strong>testing</strong><br/>
                <span class="description">test.</span>
            </td>
        </cfif>
    </tr>
</cfloop>
</tbody>
</table>

1 个答案:

答案 0 :(得分:2)

这应该有效

<cfloop list="#rating#" index="oneRating">
  <td valign="top">
      <div align="center">   
        <input type="radio" name="rating1#i#row#CurrentRow#" value="#oneRating#">
      </div><br>
  </td>
</cfloop>