1
<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

2
  • Try looking into window.location. You may have to have your button call a javascript function through onclick, which then sets the location. 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 Commented Nov 19, 2015 at 19:44

2 Answers 2

7

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>
Sign up to request clarification or add additional context in comments.

Comments

1
<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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.