不知道如何解釋這個,但我想打開一個新窗口,同時在打開的頁面上設置一個特定的單選按鈕。單選按鈕,引用外部文檔
接觸us.php(我的網頁打開)
<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.php
<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)
但是目前所有的代碼確實是上打開新的一頁!(接觸我們。 php)
我不是100%確定這可以完成,但我的最終目標是打開一個新頁面,用戶單擊圖像時已選擇收音機選項。
P.S這不是完整的代碼,因爲我只發佈了我感覺相關的partd。
您的代碼將採用模態股利或浮動DIV工作,怎麼樣吧。無論如何,彈出窗口被大多數瀏覽器阻止。 – Drew