单选按钮(INPUT type =“radio”)的OnChange事件处理程序不能作为一个值(OnChange event handler for radio button (INPUT type=“radio”) doesn't work as one value)
我正在寻找一个通用的解决方案。
考虑2个具有相同名称的无线电类型输入。 提交时,检查的值决定了以下形式发送的值:
<input type="radio" name="myRadios" onchange="handleChange1();" value="1" /> <input type="radio" name="myRadios" onchange="handleChange2();" value="2" />
当单选按钮被取消选择时,更改事件不会触发。 因此,如果已经选择了值为“1”的无线电,用户选择了第二个,则handleChange1()不会运行。 这给我一个问题(对我来说),因为没有事情可以抓住这个去选择。
我想要的是复选框组值的onchange事件的解决方法,或者检测不仅当检查无线电时,还检测无线检测时的oncheck事件。
我确信你们中有些人以前遇到这个问题。 什么是一些解决方法(或理想情况下,正确的方法来处理)? 我只想捕捉更改事件,访问先前检查的收音机以及新检查的收音机。
PS
onclick似乎是一个更好的(跨浏览器)事件来指示何时检查收音机,但仍然无法解决未检查的问题。我想这是有道理的,为什么一个复选框类型的替换在这种情况下可以工作,因为它在您检查或取消检查时更改其提交的值。 我希望单选按钮的行为更像是一个SELECT元素的onchange,但你能做什么?
I'm looking for a generalized solution for this.
Consider 2 radio type inputs with the same name. When submitted, the one that is checked determines the value that gets sent with the form:
<input type="radio" name="myRadios" onchange="handleChange1();" value="1" /> <input type="radio" name="myRadios" onchange="handleChange2();" value="2" />
The change event does not fire when a radio button is de-selected. So if the radio with value="1" is already selected and the user selects the second, handleChange1() does not run. This presents a problem (for me anyway) in that there is no event where I can can catch this de-selection.
What I would like is a workaround for the onchange event for the checkbox group value or alternatively an oncheck event that detects not only when a radio is checked but also when it is unchecked.
I'm sure some of you have run into this problem before. What are some workarounds (or ideally what is the right way to handle this)? I just want to catch the change event, access the previously checked radio as well as the newly checked radio.
P.S.
onclick seems like a better (cross-browser) event to indicate when a radio is checked but it still does not solve the un-checked problem.I suppose it makes sense why onchange for a checkbox type does work in a case like this since it changes the value that it submits when you check or un-check it. I wish the radio buttons behaved more like a SELECT element's onchange but what can you do...
原文:https://stackoverflow.com/questions/8838648
最满意答案
我能弄清楚这个问题。 在Ubuntu上,Docker将容器的DNS服务器设置为8.8.8.x的Google服务器。 据了解,这是Ubuntu的一个解决方法,因为Ubuntu将/etc/resolv.conf设置为127.0.0.1。
这些Google服务器无法从防火墙后面访问,这就是为什么我们无法解析任何URL。
这个修复是告诉Docker要使用的DNS服务器。 这个修复取决于你如何安装Docker:
Ubuntu软件包
如果您安装了Ubuntu软件包,请编辑/ etc / default / docker并添加以下行:
DOCKER_OPTS="--dns <your_dns_server_1> --dns <your_dns_server_2>"
您可以添加尽可能多的DNS服务器,您想要这个配置。 编辑此文件后,您将需要重新启动Docker服务:
sudo service docker restart
二进制
如果您已经通过二进制文件方法安装了Docker(即没有包),则在启动Docker守护程序时设置DNS服务器:
sudo docker -d -D --dns <your_dns_server_1> --dns <your_dns_server_2> &
I was able to figure out the issue. On Ubuntu, Docker sets the DNS servers for container to Google's servers at 8.8.8.x. As I understand it, this is a workaround on Ubuntu due to the fact that Ubuntu sets /etc/resolv.conf to be 127.0.0.1.
Those Google servers weren't accessible from behind our firewall, which is why we couldn't resolve any URLs.
The fix is to tell Docker which DNS servers to use. This fix depends on how you installed Docker:
Ubuntu Package
If you have the Ubuntu package installed, edit /etc/default/docker and add the following line:
DOCKER_OPTS="--dns <your_dns_server_1> --dns <your_dns_server_2>"
You can add as many DNS servers as you want to this config. Once you've edited this file you'll want to restart your Docker service:
sudo service docker restart
Binaries
If you've installed Docker via the binaries method (i.e. no package), then you set the DNS servers when you start the Docker daemon:
sudo docker -d -D --dns <your_dns_server_1> --dns <your_dns_server_2> &
相关问答
更多-
这可以通过将ADFS端点的Url添加到Internet Explorer的本地Intranet或受信任站点来实现。 默认情况下,Internet Explorer会将Windows凭据传递给这两个组中的站点。 如果这不起作用,则必须仔细检查该设置是否未被修改。 This can be accomplished by adding the Url of the ADFS endpoint to the local intranet or trusted sites of Internet Explorer. ...
-
@dkanejs是对的,这就是你如何使用它(版本号很重要): version: '3.4' services: my_image: build: context: . network: host @dkanejs is right, and here is how you use it (the version number is important): version: '3.4' services: my_image: build: cont ...
-
我能弄清楚这个问题。 在Ubuntu上,Docker将容器的DNS服务器设置为8.8.8.x的Google服务器。 据了解,这是Ubuntu的一个解决方法,因为Ubuntu将/etc/resolv.conf设置为127.0.0.1。 这些Google服务器无法从防火墙后面访问,这就是为什么我们无法解析任何URL。 这个修复是告诉Docker要使用的DNS服务器。 这个修复取决于你如何安装Docker: Ubuntu软件包 如果您安装了Ubuntu软件包,请编辑/ etc / default / docker ...
-
--network docker build命令还有一个--network参数,您可以使用该参数指定应该用于中间容器的网络模式 --network (=default)为构建期间的RUN指令设置联网模式 这应该允许您使用以下内容构建容器: docker build -t yourimagename --network=host . The docker build command also has a --network parameter that you can use to specify the ...
-
Mac的Docker运行在虚拟机中。 --net=host是指Linux VM主机网络堆栈而不是OSX。 除映射端口之外,没有从OSX到Docker VM的直接网络路径。 Docker for Mac中的映射端口( docker run -p Y:N )有点特别,除了通常在Docker主机上运行的用户空间代理之外,Docker for Mac还在OSX上启动用户空间代理以侦听相同的端口和转发连接到虚拟机。 当使用--net=host时,OSX进程不会启动(而Linux的进程当然不是)。 → docker r ...
-
对于容器到容器的通信,没有必要发布目标端口,您将直接与目标容器通信。 目标容器中的应用程序需要侦听所有接口(0.0.0.0,而不是127.0.0.1)。 假设是这种情况,您应该能够连接: http://server1:4000/api/requestnode 服务器启动后。 请注意,客户端可以在服务器之前启动,因此您需要实现某种形式的重试或等待脚本,以确保服务器首先启动。 For container-to-container communication, it's not necessary to pub ...
-
如何在DigitalOcean与Docker进行通信(网络)?(How to communicate (network) with Docker at DigitalOcean?)[2021-10-09]
如果你用工具箱安装docker,这是修复: # run the container with all IPs, do not limit to 127.0.1.1 $ docker run -d --name tor_instance -p 9150:9150 nagev/tor # find out the docker IP $ docker-machine ip default 192.168.99.100 # test the IP and port is available. telnet 1 ... -
您可以查看docker run退出代码。 如果它不是0,则中止脚本。 for file in src/main/thrift/*.thrift; do echo "Compiling ${file}" docker run {...} thrift:${THRIFT_VERSION} thrift {...} if [ $? != 0 ]; then exit -1 fi done You can check docker run exit code. If ...
-
经过一番调查,我意识到我的基本图像是问题,我正在使用: mhart/alpine-node:6.9.1 切换到 kkarczmarczyk/node-yarn 做了伎俩。 我想Alpine节点很小,并且正在删除对代理/网络配置很重要的东西 After some investigation I realised that my base image was the problem, I was using: mhart/alpine-node:6.9.1 Switching to kkarczmarczyk/ ...
-
These industry standard build tools surely do not make 'inherently dubious use of the HTTP protocol', right? 如果任何这些工具(特别是Maven)做任何可疑的事情,我真的会感到非常惊讶。 代码是开放的,在那里,我相信人们已经知道它是否做了任何恶意的事情。 特别谈到Maven Central,Maven Central中部署的所有罐子都需要用GPG密钥签名。 此外,文件还使用SHA校验和进行保护,以确保 ...