2014-03-26 13 views
-1

我希望我的客戶在那裏添加URL,再加上從下拉列表中選擇以完成URL,點擊按鈕進入新頁面。HTML - 輸入並選擇到URL

<form name="form1" method="post" action=""> 
<label>http://www. 
<input type="text" name="input1" id="input1" value="mydomain.com"> 
</label> 
/
<select name="select" id="select"> 
<option value="Select" selected>Select</option> 
<option value="cPanel">cPanel</option> 
<option value="Webmail">Webmail</option> 
</select> 
<label> 
<input type="submit" name="button1" id="button1" value="Submit"> 
</label> 
</form> 

什麼仍然必須添加到上述簡單的HTML代碼,(這只是格式),所以我的客戶只需要添加有域,請從下拉選項下點擊提交帶他們到那裏各自的登錄屏幕。該鏈接將是典型的:

http://example.com/cpanelhttp://example.com/webmail

+0

和你的問題是什麼? –

+0

問題請 –

回答

1

我收到這個答案罰款克里斯在雅虎問答,以爲我會分享答案。

http://jsfiddle.net/khrismuc/gwM9K/

<form onsubmit="return go(this.where.value, this.which.value)"> 
http:// 
<input type="text" name="where" id="input1" value="www.mydomain.com" />/ 
<select name="which" id="select"> 
    <option value="Select">Select</option> 
    <option value="cPanel">cPanel</option> 
    <option value="Webmail">Webmail</option> 
</select> 
<input type="submit" name="button1" id="button1" value="Submit" /> 
</form> 

// https://answers.yahoo.com/question/index?qid=20140327005411AAk9zW1 
// form -> go to url 

var go = function(where, which) { 
if (which === "Select") return false; 
// change option to url part 
if (which === "cPanel") which = "cpanel"; 
if (which === "Webmail") which = "webmail"; 
document.location.href = "http://" + where + "/" + which; 
return false; 
};