javascript - add values from select box to URL dynamically in HTML5 -
i have simple html5 code opens new tab when click on button url depending on value client value of select box, wonder how can include values name , language components url parameters in selectbox, building (using jquery notation)
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, agree on our <a href="#">terms , 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>
easy:
<a href="#" onclick="javascript:location.href = id_hosp.value + '/?lang=' + langu.value.slice(0,2) +'&name=' + names.value;" target="_blank" class="button">login</a>
code
<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, agree on our <a href="#">terms , 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>
Comments
Post a Comment