Codeigniter:如何为DISC测试制作动态单选按钮?

时间:2016-08-07 15:37:32

标签: javascript php jquery codeigniter

我想进行DISC测试,它有8个单选按钮。我试过了this。但它不起作用。 这是我的代码:

power.value

我想在<script> $(".radioGroup input").change( function(){ i= $(this).index(); sibling = $(this).parent() .siblings() .find("input") .eq(i); if (sibling.is(":checked")) $(this).removeAttr("checked"); } ); </script> <?php echo "<table class=\"input\" cellpadding=\"1\" >"; echo " <tr align=\"center\"> <th>Most</th> <th>Less</th> <th>Statement</th>"; echo " </tr>"; echo " <tr> <td align=\"left\"><input type=\"radio\" name=\"p_jwb\" value=\"1\"></td> <td align=\"left\"><input type=\"radio\" name=\"k_jwb\" value=\"1\"></td> <td align=\"left\" bgcolor=\"#C0C0C0\">Powerfull"; echo " </td></tr>"; echo " <tr> <td align=\"left\"><input type=\"radio\" name=\"p_jwb\" value=\"1\"></td> <td align=\"left\"><input type=\"radio\" name=\"k_jwb\" value=\"1\"></td> <td align=\"left\" bgcolor=\"#C0C0C0\">Brave"; echo " </td></tr>"; echo " <tr> <td align=\"left\"><input type=\"radio\" name=\"p_jwb\" value=\"1\"></td> <td align=\"left\"><input type=\"radio\" name=\"k_jwb\" value=\"1\"></td> <td align=\"left\" bgcolor=\"#C0C0C0\">Leadership"; echo " </td></tr>"; echo " <tr> <td align=\"left\"><input type=\"radio\" name=\"p_jwb\" value=\"1\"></td> <td align=\"left\"><input type=\"radio\" name=\"k_jwb\" value=\"1\"></td> <td align=\"left\" bgcolor=\"#C0C0C0\">Honest"; echo " </td></tr>"; echo "</table>"; ?> 中选择一个,在Most中选择一个,例如LessMost Honest。我想制作,如果我选择Less Powerfull,然后点击Most Honest,就会发出警告,我必须选择其他声明。怎么解决?

1 个答案:

答案 0 :(得分:0)

From What i understand from your question,as per your expectation You should set same name as same Statement . For eg.


echo "  <tr align=\"center\">
                <th>Most</th>
                <th>Less</th>
                <th>Statement</th>";
        echo "  </tr>";

        echo "  <tr>
                <td align=\"left\"><input type=\"radio\" name=\"p_jwb\" value=\"1\"></td>
                <td align=\"left\"><input type=\"radio\" name=\"p_jwb\" value=\"1\"></td>
                <td align=\"left\" bgcolor=\"#C0C0C0\">Powerfull";
        echo "  </td></tr>";

echo "  <tr>
                <td align=\"left\"><input type=\"radio\" name=\"k_jwb\" value=\"1\"></td>
                <td align=\"left\"><input type=\"radio\" name=\"k_jwb\" value=\"1\"></td>
                <td align=\"left\" bgcolor=\"#C0C0C0\">Brave";
        echo "  </td></tr>";



echo "  <tr>
                <td align=\"left\"><input type=\"radio\" name=\"kp_jwb\" value=\"1\"></td>
                <td align=\"left\"><input type=\"radio\" name=\"kp_jwb\" value=\"1\"></td>
                <td align=\"left\" bgcolor=\"#C0C0C0\">Leadership";
        echo "  </td></tr>";

        echo "  <tr>
                <td align=\"left\"><input type=\"radio\" name=\"pk_jwb\" value=\"1\"></td>
                <td align=\"left\"><input type=\"radio\" name=\"pk_jwb\" value=\"1\"></td>
                <td align=\"left\" bgcolor=\"#C0C0C0\">Honest";
        echo "  </td></tr>";

  echo "</table>";