0

I'm trying to build a... link builder to ease some of my day-to-day tasks. I can't make it work though, and would really appreciate some help:

<form target="">
  ID one:
  <input type="text" name="IDone" id="ID1">
  
  ID two:
  <input type="text" name="IDtwo" id="ID2">
  
  <button value="go" id="myButton">build</button>
  
  <script type="text/javascript">
    document.getElementById("myButton").onclick = function () {
        location.href = 
          "https://first.part.com/" + document.getElementById("ID1").value +
          "?act=setsecond_part=" + document.getElementById("ID2").value;
    };
  </script>
  
</form>

The idea is very simple:

  • first field (ID one) gets the data that's put in it;
  • second field (ID two) gets the data that's put in it;
  • the "build" button actually goes to link that's comprised of https://first.part.com/ + + <?act=setsecond_part=> + <"ID2">.

Thank you for your assistance!

JPM

4
  • 1
    It is really hard to read code like this. Commented Oct 10, 2016 at 9:47
  • didn't see that one coming, thanks a bunch for the edit! Commented Oct 10, 2016 at 9:54
  • Does the function ever get called? If yes, what is the value of location.href after the call? Commented Oct 10, 2016 at 9:59
  • Hi, no, it doesn't get called; don't know how I thought the "build" button would call it... Can you suggest how to call the function through the "build" button so it actually goes to the newly built link? Commented Oct 10, 2016 at 10:01

1 Answer 1

1

Delete a form tag and everything will be work fine :)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks!!! :) Don't know why the <form> </form> was messing it up, but now it's working.

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.