在HTML5中动态地将选择框中的值添加到URL

时间:2016-01-27 11:26:24

标签: javascript jquery html html5

我有这个简单的HTML5代码,当你点击按钮到一个URL取决于选择框的客户端值的值时打开一个新选项卡,我想知道如何将名称和语言组件的值包含到URL参数中在selectbox中,用于构建这样的东西(使用jquery表示法)

值= “HTTP://本地主机:1010 / LAN = $( '#lang').VAL()及名称= $( '#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>

1 个答案:

答案 0 :(得分:0)

易:

var options=null;
if(data.getNumberOfRows()>7){
    options = {
        width : 600,
        height:235,
        sort : 'enable',
        sortColumn : 1,
        sortAscending : false,
        scrollLeftStartPosition : 50,
        showRowNumber : true,
        chartArea : chartArea,
        cssClassNames : cssClassNames   
    };
}else{
    options = {
        width : 600,
        sort : 'enable',
        sortColumn : 1,
        sortAscending : false,
        scrollLeftStartPosition : 50,
        showRowNumber : true,
        chartArea : chartArea,
        cssClassNames : cssClassNames   
    };
}

代码

   <a href="#" onclick="javascript:location.href = id_hosp.value + '/?lang=' + langu.value.slice(0,2) +'&name=' + names.value;" target="_blank" class="button">Login</a>