0

I have a form:

<form method="post" action="/whatIwroteintotheInputfield">
  <input type="text" onchange="this.form.submit();"></input>
</form>

The form is being posted after inserting a value. Now I don't just want to refresh the site, but redirecting to /whatIwroteintotheInputfield.

How can I achieve that?

Thanks for reading!

Nana Partykar
  • 10,556
  • 10
  • 48
  • 77
Skalibran
  • 459
  • 1
  • 5
  • 19

1 Answers1

2
<form method="post" action="yourTextURL">
    <input type="text" id="changeText" value="http://"></input>
</form>

<script src="https://code.jquery.com/jquery-1.10.2.js"></script>

<script>
    $("#changeText").on('change', function() {
          var url = $('#changeText').val();
          window.location = url;
    });
</script>

For more info, check on change() & Change URL

And, one question from my side. Why you need <form></form> then. It can be done without <form> too. So, if possible (if no need), then remove <form></form>.

Community
  • 1
  • 1
Nana Partykar
  • 10,556
  • 10
  • 48
  • 77