-1

I want to create a form like popup that has a input and a button. When i type in an input Ex.: "good" and click on button it go to the url "good.mydomain.com"

i did this but it doest work

<html>
    <form action="firstname.mydomain.com">
    Go to URL:<br>
    <input type="text" name="firstname" value="">.mydomain.com
    <br>
    <p>
    <input type="submit" value="go">
    </p>
    </form> 
</html>
kcm
  • 1
  • Try the suggestion in this question: http://stackoverflow.com/questions/2701041/how-to-set-form-action-through-javascript – Always Learning May 25 '15 at 02:51
  • possible duplicate of [How to create an HTML button that acts like a link?](http://stackoverflow.com/questions/2906582/how-to-create-an-html-button-that-acts-like-a-link) – Ken Y-N May 25 '15 at 03:00

2 Answers2

-1

You could achieve this with jQuery.

The HTML:

<input type="text" id="goTo" name="firstname">.mydomain.com
<input type="submit" id="myButton" value="Go">

Then the jQuery:

$('#myButton').click(function() {
    var goTo = $("#goTo").val();
    window.location.href = 'http://'+goTo+'.mydomain.com/';
    return false;
});
Axiom
  • 902
  • 1
  • 10
  • 23
-1

please try below code using javascript.

<html>
<head>
    <title>Submit</title>
    <script>
        function Submit() {
            var url = "http://www." + document.getElementById("firstname").value + ".mydomain.com";
            window.location.assign(url);
        }
    </script>
</head>
<body>
    Go to URL:<br>
    <input type="text" name="firstname" id="firstname" value="">.mydomain.com
    <br>
    <p>
        <input type="button" value="go" onclick="Submit()">
    </p>


</body>
</html>​​
  • i guess it is ok, but at the end a see this characters " ​​ ", what its? – kcm May 25 '15 at 12:54
  • I don't see these special characters. From where it came? – Imran Saddapalli May 25 '15 at 13:08
  • I guess it may be because of copy paste of code.. I don't see that in my file. – Imran Saddapalli May 25 '15 at 16:32
  • Yes it great solutions. :( i cant used in a wordpress page. i want to put a button and when some one click on that button it popup the form. – kcm May 26 '15 at 16:45
  • i could put the form in a post, but the button go doesnt go to the link – kcm May 26 '15 at 16:48
  • Hi Imran Saddapalli i have a ex.: what a want. http://www.vendhq.com/ in this page when you click on sing in, apear a popup with the input and button. Can you see, please? – kcm May 27 '15 at 03:25
  • i could create the popup, but when i click on go botton it open in the same popup, i would like that open in the source page. – kcm Jun 10 '15 at 20:27