我是Javascript的總noob。我想要的是有一個搜索表單,並且表單的輸入應該改變網址,然後它會打開一個新的標籤與新的網址。Javascript替換HTML字符
例如,當我輸入'production'時,url將變成http://production-test.com/test/,然後一個新標籤頁將打開並顯示新的url。
我知道這應該是在Javascript中,但我不知道它將如何能夠返回新的url。
我有這個HTML到目前爲止根本不工作。
<script language="javascript">
function change_url(result) {
#var result = document.getElementById().value;
var new_url = "http://" + result + "-test.com/test/';
# open new window with the new url
}
<form id="search-box" name="search_box" method="get"
action="http://variable-test.com/test/" target="_blank"">
<input id="search-text" type="text" autocomplete="off"
class="form-text-box no-focus" name="c" value="" aria-haspopup="true">
<input type="radio" id="rel" name="sort" value="1" onchange="saveType('rel');" /><span data-message="TypeOp1">Relevance</span><br />
<input id="search-button" type="submit" />
已有進展。感謝莫爾博士。但是現在我不知道如何傳遞參數?從Dr. Molle腳本... form.action =「.../test /?」 +「new_paramters」。出於某種原因,放棄問號後的任何內容。 – Carmen 2012-04-01 04:49:29