<input type="text" name="my_sld" style="width: 55%" value="">
<br />
<select name="my_tld" style="width: 20%">
<option value="" label=""> </option>
<option value="net" label="net"> </option>
<option value="org" label="org"> </option>
</select>
<script>
var sld = my_sld();
var tld = my_tld();
var domain = sld + tld;
</script>
<button go to = / + domain + >
how to make my_sld + my_tld go to mysite when i click the button via javascript?
for example =
<input type="text" name="my_sld" style="width: 55%" value="">
<br />
<select name="my_tld" style="width: 20%">
<option value="" label=""> . </option>
<option value="net" label="net"> </option>
<option value="org" label="org"> </option>
</select>
<script>
var sld = my_sld();
var tld = my_tld();
var domain = sld + tld;
</script>
<button go to = http://example./check/ + domain + >
how to make my_sld + my_tld go to mysite when i click the button via javascript?
for example = http://example./check?domain=thedomainname
Share Improve this question edited Nov 19, 2015 at 20:09 Petr Felzmann 1,3134 gold badges20 silver badges39 bronze badges asked Nov 19, 2015 at 19:37 Selakarweb di siniSelakarweb di sini 111 silver badge3 bronze badges 2-
Try looking into
window.location
. You may have to have your button call a javascript function through onclick, which then sets the location. – Nate Young Commented Nov 19, 2015 at 19:41 - Give to the input text and to the select an id attribute then load the value with jquery. You can append that value to the url – Antonio Commented Nov 19, 2015 at 19:44
2 Answers
Reset to default 7You should do like this..
First provide any ID to button :
<button id=“test” value=“click">
Then in javascript you should do like:
<script>
$("#test").click(function(){
var sld = my_sld();
var tld = my_tld();
var domain = sld+tld;
window.location.href="http://example./check?domain="+domain;
})
</script>
<script>
function redirect() {
window.location = 'http://example./check/' + sld + tld;
}
</script>
<button onclick='redirect();'>
or with unobtrusive and still pure javascript
<button id='redirect'>
<script>
document.getElementById('redirect').onclick = function() {
window.location = 'http://example./check/' + sld + tld;
};
</script>