[英]Dynamically add html select onClick of another select box option
[英]add values from select box to URL dynamically in HTML5
我有這個簡單的HTML5代碼,當您單擊URL的按鈕時,它會打開一個新選項卡,具體取決於選擇框的客戶端值中的值,我想知道如何將名稱和語言組件中的值包含到選擇框中的URL參數中,用於構建類似的內容(使用jquery表示法)
value =“ http:// localhost:1010 /?lan = $('#lang').val()&name = $('#name').val()”
<script type="text/javascript">
window.open = function(){
location.href=document.getElementById("selectbox").value;
}
</script>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600' rel='stylesheet' type='text/css'>
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" href="style.css" />
<body>
<div class="testbox">
<h1>Portal</h1>
</br>
</br>
<form action="/">
<label id="icon" for="name"><i class="icon-user"></i></label>
<input type="text" name="name" id="name" placeholder="Name" required/>
<label id="icon" for="name"><i class="icon-shield"></i></label>
<input type="password" name="name" id="name" placeholder="Password" required/>
<div class='form-group'>
<label class='control-label col-md-2 col-md-offset-2' for='id_accomodation'>Client</label>
<div class='col-md-2'>
<select class='form-control' id='id_hosp'>
<option value="http://localhost:1010">HUCA</option>
<option value="http://localhost:2020">HUSD</option>
<option value="http://localhost:3030">CVAL</option>
<option value="http://localhost:4040">HPH</option>
<option value="http://localhost:5050">HHENA</option>
</select>
</div>
</br>
<label class='control-label col-md-2 col-md-offset-2' for='language'>Language</label>
<div class='col-md-2'>
<select class='form-control' id='lang'>
<option >ENG</option>
<option >ESP</option>
<option >PORT</option>
</select>
</div>
</br>
</br>
</div>
<p>By clicking Register, you agree on our <a href="#">terms and condition</a>.</p>
<a href="#" onclick="javascript:location.href = id_hosp.value;" target="_blank" class="button">Login</a>
</form>
</div>
</br>
</br>
</br>
</br>
</br>
</br>
</br>
</br>
</br>
</body>
簡單:
<a href="#" onclick="javascript:location.href = id_hosp.value + '/?lang=' + langu.value.slice(0,2) +'&name=' + names.value;" target="_blank" class="button">Login</a>
碼
<form action="/">
<label id="icon" for="name"><i class="icon-user"></i></label>
<input type="text" name="name" id="names" placeholder="Name" required/>
<label id="icon" for="name"><i class="icon-shield"></i></label>
<input type="password" name="name" id="pw" placeholder="Password" required/>
<div class='form-group'>
<label class='control-label col-md-2 col-md-offset-2' for='id_accomodation'>Client</label>
<div class='col-md-2'>
<select class='form-control' id='id_hosp'>
<option value="http://localhost:1010">HUCA</option>
<option value="http://localhost:2020">HUSD</option>
<option value="http://localhost:3030">CVAL</option>
<option value="http://localhost:4040">HPH</option>
<option value="http://localhost:5050">HHENA</option>
</select>
</div>
</br>
<label class='control-label col-md-2 col-md-offset-2' for='language'>Language</label>
<div class='col-md-2'>
<select class='form-control' id='langu'onchange="javascript:location.href = this.value;">
<option value="en.html" selected="selected">ENG</option>
<option value="es.html">ESP</option>
<option value="po.html">PORT</option>
</select>
</div>
</br>
</br>
</div>
<p>By clicking Login, you agree on our <a href="#">terms and condition</a>.</p>
<a href="#" onclick="javascript:location.href = id_hosp.value + '/?lang=' + langu.value.slice(0,2) +'&name=' + names.value;" target="_blank" class="button">Login</a>
</form>
</div>
</br>
</br>
</br>
</br>
</br>
</br>
</br>
</br>
</br>
</body>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.