Javascript从弹出式输入无线电类获取值
是否有任何可能的方法从类中获取输入的无线电值信息(外部) 我尝试了一百万次 以下是我的代码: Parent.htmJavascript从弹出式输入无线电类获取值,javascript,html,class,Javascript,Html,Class,是否有任何可能的方法从类中获取输入的无线电值信息(外部) 我尝试了一百万次 以下是我的代码: Parent.htm <html> <head> <title></title> </head> <body> <input type="text" id="txtName" readonly="readonly" /> <input type="button
<html>
<head>
<title></title>
</head>
<body>
<input type="text" id="txtName" readonly="readonly" />
<input type="button" value="Select Name" onclick="SelectName()" />
<script type="text/javascript">
var popup;
function SelectName() {
popup = window.open("Popup.htm", "Popup", "width=300,height=100");
popup.focus();
return false
}
</script>
</body>
</html>
<html>
<body>
<form class="ddlNames">
<input type="radio" name="ddlNames" id="num" value="one">
<input type="radio" name="ddlNames" id="num" value="two">
<input type="radio" name="ddlNames" id="num" value="three">
</form>
<br />
<br />
<input type="button" value="Select" onclick="SetName();" />
<script type="text/javascript">
function SetName() {
if (window.opener != null && !window.opener.closed) {
var txtName = window.opener.document.getElementById("txtName");
txtName.value = document.getElementsByClassName("ddlNames")[0].value;
}
window.close();
}
</script>
</body>
</html>
var弹出窗口;
函数SelectName(){
popup=window.open(“popup.htm”,“popup”,“宽度=300,高度=100”);
popup.focus();
返回错误
}
这是一个我无法定义的页面,用来获取有价值的信息
Popup.htm
<html>
<head>
<title></title>
</head>
<body>
<input type="text" id="txtName" readonly="readonly" />
<input type="button" value="Select Name" onclick="SelectName()" />
<script type="text/javascript">
var popup;
function SelectName() {
popup = window.open("Popup.htm", "Popup", "width=300,height=100");
popup.focus();
return false
}
</script>
</body>
</html>
<html>
<body>
<form class="ddlNames">
<input type="radio" name="ddlNames" id="num" value="one">
<input type="radio" name="ddlNames" id="num" value="two">
<input type="radio" name="ddlNames" id="num" value="three">
</form>
<br />
<br />
<input type="button" value="Select" onclick="SetName();" />
<script type="text/javascript">
function SetName() {
if (window.opener != null && !window.opener.closed) {
var txtName = window.opener.document.getElementById("txtName");
txtName.value = document.getElementsByClassName("ddlNames")[0].value;
}
window.close();
}
</script>
</body>
</html>
函数SetName(){
if(window.opener!=null&&!window.opener.closed){
var txtName=window.opener.document.getElementById(“txtName”);
txtName.value=document.getElementsByClassName(“ddlNames”)[0]。value;
}
window.close();
}
我也试过这样做:
<input type="radio" class="ddlNames" name="ddlNames" id="num" value="one">
<input type="radio" class="ddlNames" name="ddlNames" id="num" value="two">
<input type="radio" class="ddlNames" name="ddlNames" id="num" value="three">
要为每个对象赋予
ddlNames
类,但该类不起作用?可以使用查询选择器获取选中值
document.querySelector('input[name="ddlNames"]:checked').value;
可以使用查询选择器获取选中的值
document.querySelector('input[name="ddlNames"]:checked').value;
嗯,你的意思是,为了不使用类,只使用包含ddlNames的名称:/lets tryOmg你保存了我的工作,我不得不创建5个弹出页面,正因为如此。非常感谢^^hmmm所以你的意思是,为了不使用类,只使用包含ddlNames的名称:/lets tryOmg你保存了我的工作,我不得不创建5个弹出页面,正因为如此。非常感谢,对不起,我的问题可能会吸引更多的人,因为这个题目。我没有找到你发给我的帖子,希望这篇帖子能帮助其他人找到更简单的解决方案。希望你能理解我,一切顺利。对不起,我的问题可能会吸引更多的提问者,因为标题。我没有找到你发给我的帖子,希望这篇帖子能帮助其他人找到更简单的解决方案。希望你能理解我,祝你一切顺利。