View Full Version : Onclick Not Working?
adamjblakey
Mar 21st 2008, 2:35 am
Hi,
Can someone help me with this:
<input type="submit" name="Submit" value="Find" onclick="location.href="http://www.web.co.uk/" + document.getElementById("service").value + "/" + document.getElementById("location").value + "/";"/>
It does not seem to work but cannot see what is wrong with it.
Cheers,
Adam
hogan_h
Mar 21st 2008, 3:50 am
There is syntax error there because the quotes are not properly enclosed/used.
Try this:
<input type="submit" name="Submit" value="Find" onclick="location.href='http://www.web.co.uk/' + document.getElementById('service').value + '/' + document.getElementById('location').value + '/';" />
vpguy
Mar 21st 2008, 4:56 pm
You also might want to consider putting that code into the <form> tag (but use onsubmit instead of onclick), and follow it up with a return false; to make sure the form doesn't accidentally get posted.
For example:
<form onsubmit="location.href='http://www.web.co.uk/' + document.getElementById('service').value + '/' + document.getElementById('location').value + '/'; return false;">
adamjblakey
Mar 22nd 2008, 1:49 am
Thanks this works fine now,
What i need to do, and i don't know if this is possible but i need when a selection is made i need that selection if contains spaces for the spaces to be removed and replaced with - also i need the address to be changed to all lowercase.
Can this be done, if so how?
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.