0

I have got a problem.

I need to have an simple input form which will change the relative URL of the page. Lets say i've got site.com/index

<form>
<p>
  <label for="url"</label>
  <input id="url" type="text" onchange="var a = document.createElement('a');
  a.setAttribute('href', this.value); this.value = a.href; window.location.search="/a.href";" placeholder="Search">
  <button type="submit">Submit</button>
</p> </form>

Where did i go wrong? Whatever i type in the form, it will redirect me to site.com/index?
Maybe i got it wrong and this can only be handled on the backend.

Thanks in advance.

1 Answer 1

1

Try the folloiwng

<form>
<p>
  <label for="url"</label>
  <input id="url" type="text" onchange="window.location='/'+this.value;" placeholder="Search">
  <button type="submit">Submit</button>
</p> </form>
Sign up to request clarification or add additional context in comments.

1 Comment

Nope, didn't work - still redirects page to index?.

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.