选择表格中的行或列中的单选按钮

时间:2018-01-16 18:40:14

标签: javascript html css radio-button

我有以下标记:



public static void connectToWifi(String ssid, String pass){
    WifiManager myWifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    WifiConfiguration conf = new WifiConfiguration();
    conf.SSID = "\"" + ssid + "\"";
    conf.preSharedKey = "\""+ pass +"\"";
    conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);


    List<WifiConfiguration> list = MainActivity.wifi.getConfiguredNetworks();
    for( WifiConfiguration i : list ) {
        if(i.SSID != null && i.SSID.equals("\"" + ssid + "\"")) {
            MainActivity.wifi.disconnect();
            MainActivity.wifi.enableNetwork(i.networkId, true);
            MainActivity.wifi.reconnect();
            break;
        }
    }
}
&#13;
&#13;
&#13;

这是一张3x3的桌子,里面有9个单选按钮。我想配置它以便我可以:

  • 每行选择仅1 单选按钮或
  • 每列选择仅1 单选按钮

这可能没有任何JavaScript吗?谢谢!

1 个答案:

答案 0 :(得分:5)

您可以使行/列中的输入(根据您的需要)具有相同的名称,以便只能检查其中一个。

每行一个

<table>
  <tr>
    <td><input type="radio" name="radio1"></td>
    <td><input type="radio" name="radio1"></td>
    <td><input type="radio" name="radio1"></td>
  </tr>
  <tr>
    <td><input type="radio" name="radio2"></td>
    <td><input type="radio" name="radio2"></td>
    <td><input type="radio" name="radio2"></td>
  </tr>
  <tr>
    <td><input type="radio" name="radio3"></td>
    <td><input type="radio" name="radio3"></td>
    <td><input type="radio" name="radio3"></td>
  </tr>
</table>

每列一个

<table>
  <tr>
    <td><input type="radio" name="radio1"></td>
    <td><input type="radio" name="radio2"></td>
    <td><input type="radio" name="radio3"></td>
  </tr>
  <tr>
    <td><input type="radio" name="radio1"></td>
    <td><input type="radio" name="radio2"></td>
    <td><input type="radio" name="radio3"></td>
  </tr>
  <tr>
    <td><input type="radio" name="radio1"></td>
    <td><input type="radio" name="radio2"></td>
    <td><input type="radio" name="radio3"></td>
  </tr>
</table>