单选按钮,参考外部文件

radio button, reference external document

本文关键字:文件 外部 参考 单选按钮      更新时间:2023-09-26

不知道如何解释这一点,但我正试图打开一个新窗口,同时在打开的页面上设置一个特定的单选按钮。

Contact-us.php (my page to Open)

<form name="f2" method="post" action="send_form_email3.php" id="Homeform1" onsubmit="return checkEmail(this)">
<input type="radio" name="package" value="Option1"> Basic 
<input type="radio" name="package" value="Option2"> Silver
<input type="radio" name="package" value="Option3"> Gold
<input type="radio" name="package" value="Custom"> Custom

这个页面有

按钮

home。

<a href="javascript:win1=window.open('contact-us.php'); setCheckedValue(win1.document.forms['f2'].elements['package'], 'Option2');" id="link2" class="links"></a>

这是JS文件

function setCheckedValue(radioObj, newValue) {
if(!radioObj)
    return;
var radioLength = radioObj.length;
if(radioLength == undefined) {
    radioObj.checked = (radioObj.value == newValue.toString());
    return;
}
for(var i = 0; i < radioLength; i++) {
    radioObj[i].checked = false;
    if(radioObj[i].value == newValue.toString()) {
        radioObj[i].checked = true;
    }
}

}

它适用于同一页面,如果我把表单和按钮(home。php)放在同一页面

然而,目前所有的代码都是打开一个新的页面!(Contact-us.php)

我不能100%确定这可以做到,但我的最终目标是打开一个新的页面,当用户点击一个图像时,已经选择了单选选项。

p。这不是完整的代码,因为我只发布了我觉得相关的部分。

您可以将参数传递给contact-us.php?checkedValue=...,并使用php或Javascript读取它们。

或者你可以在contact-us.php中加入Javascript代码来读取父窗口中的值,比如parent.yourGlobalObject.checkedValue