Forum Moderators: phranque

Message Too Old, No Replies

HTML to open a url based on Form input

         

shorthound

3:54 pm on Jul 19, 2018 (gmt 0)

5+ Year Member



similar to this topic...new to all this.
[webmasterworld.com...]

I'd like to have a form with 1 input box for a UserID.
A number value with no less than 8 chars and no more than 9 ie 12345678 or 123456789

That UserID would then be appended to this url...

https://example.org/Volunteers/ViewCertification?UserID=12345678

I would like it to open to a new window with the url formed above.

Thanks for any help.






When the user presses the submit button, I would like it to

[edited by: phranque at 5:52 pm (utc) on Jul 19, 2018]

keyplyr

11:06 pm on Jul 19, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi shorthound and welcome to WebmasterWorld [webmasterworld.com]

shorthound

11:14 pm on Jul 19, 2018 (gmt 0)

5+ Year Member



hello and thanks!

tangor

11:42 pm on Jul 19, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Most likely you will need more than HTML to secure, sanitize, and vet the input before passing it on.

lucy24

12:08 am on Jul 20, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This kind of thing is generally done with javascript [webmasterworld.com]. First step is to make a form that receives the input; second step is to process the input, make sure it contains everything it’s supposed to and nothing it isn’t; third step is to form the new URL and request it.

When the user presses the submit button, I would like it to
Uh-oh, phranque, you’re not implying he’d like it to do something naughty, are you?

shorthound

12:40 am on Jul 20, 2018 (gmt 0)

5+ Year Member



unfortunately I think I am constrained to very limited html. using a vendors tool that provides an html content module but very little else.

functions dont work, javascript doesnt seem to work

there isnt anyway to just accept input from one field and append that value to a static url?

I've been mainly on the application side of things, not so much the programming side.

thanks again

lucy24

1:31 am on Jul 20, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



HTML by itself can handle the input aspect of forms. But it cannot do anything with the input except hand it off to some other entity, such as a script or php.

NickMNS

1:41 am on Jul 20, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Here:

<form action="/Volunteers/ViewCertification.html">
User ID:<br>
<input type="number" max="9999999" name="uid">
<br><br>
<input type="submit" value="Submit">
</form>


This will submit a get request to the server with url http://www.mydomain.com/Volunteers/ViewCertification.html?uid=[whatever you enter in the field]
Provided that your server can redirect the request to the correct page it will take it there with only html5



[edited by: not2easy at 3:36 am (utc) on Jul 20, 2018]
[edit reason] unlinked example URL [/edit]

NickMNS

2:00 am on Jul 20, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I just would like to elaborate on Lucy24's point
second step is to process the input, make sure it contains everything it’s supposed to and nothing it isn’t;

In my example I used a very simplified means of validation setting type to number and max to "99999999". This is not likely sufficient for your needs, you should probably use type="text" and then define a pattern using regex to rigorously limit the possible entries to desired values.