HTML/Jave dialog box which parses to an address?

Soldato
Joined
5 Jul 2007
Posts
2,571
Location
NZ
Hi all coding gurus!

What I'm looking for is some code which adds a "Submit" button and one text box called "Event ID". What will happen is someone will simply type in the ID number and click submit and the page brought up will be www.mywebsite.com/events/XXX where XXX is whatever was typed in!

I'm thinking this is simple code but cant see how to do it as I'm not a coder :(

Any help would be great! Cheers
 
Forms generally don't work like that by themselves, so you'd either have to use a server-side language to redirect the user, or use some JavaScript:
Code:
<script type="text/javascript">
function submitIt(id)
{
	elem = document.getElementById(id);
	window.location = 'http://mywebsite.com/events/' + elem.value;
}
</script>

<form onsubmit="submitIt('eventID'); return false;">
 <!-- Inline JS rather than event handling to keep things simple -->
 <input type="text" id="eventID">
 <button type="submit">Submit</button>
</form>
 
Back
Top Bottom