1

I want to create a static webpage which has a text field and a submit button, which after a user submits text it would automatically redirect from localhost/ to localhost/<test_person_submitted> .

Up to this point, this JavaScript is the only thing I was able to clobber together from all of the guides I found

function confirmInput() {
  fname = document.forms[0].fname.value;
  url = "http://localhost/"
  command = (url + fname)
  location.replace(command);
}

That does work, but no matter what I added as HTML to invoke the function it doesn't work properly.

Can someone please add a submit form that will properly execute this? Right now I'm stumped and I just want to consider this small project "complete", rather to just leaving it without ever knowing how it could be resolved.

If you are wondering why I want to do this it's because I'm going to try to invoke some wild-card commands that will return JSON. And this is just a fun project for me.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
  • 1
    Does this answer your question? [How do I redirect to another webpage?](https://stackoverflow.com/questions/503093/how-do-i-redirect-to-another-webpage) – DaFois Jun 03 '21 at 15:42
  • 1
  • okay, the text that gets entered, lets say "page1" does page1 already exists in files? as page1.html or something like that –  Jun 03 '21 at 16:18
  • Please do not edit solution announcements into the question. Accept (i.e. click the "tick" next to it) one of the existing answer, if there are any. You can also create your own answer, and even accept it, if your solution is not yet covered by an existing answer. – Yunnosch Jun 04 '21 at 07:13

0 Answers0