Reputation: 11
<input type="text" name="my_sld" style="width: 55%" value="">
<br />
<select name="my_tld" style="width: 20%">
<option value="com" label="com"> .com </option>
<option value="net" label="net"> .net </option>
<option value="org" label="org"> .org </option>
</select>
<script>
var sld = my_sld();
var tld = my_tld();
var domain = sld + tld;
</script>
<button go to = http://example.com/check/ + domain + >
how to make my_sld + my_tld go to mysite when i click the button via javascript?
for example = http://example.com/check?domain=thedomainname.net
Upvotes: 1
Views: 3480
Reputation: 994
You 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.com/check?domain="+domain;
})
</script>
Upvotes: 7
Reputation: 1313
<script>
function redirect() {
window.location = 'http://example.com/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.com/check/' + sld + tld;
};
</script>
Upvotes: 1