I have a form which at the moment when I submit it, it takes me to a url www.domain.com/search/?maxprice=10000000, however what I want it to do is to take me to a custom url e.g. www.domain.com/search/maxprice_10000000/
I found this javascript code which was meant to allow custom urls by stopping the form from doing its default action using event.preventDefault() However this either isnt working or isnt loading in the first place
Here is my code:
<script type="text/javascript">
$(document).ready(function() {
$("#propertysearch").submit(function(event) {
event.preventDefault();
window.location.href = "/"; //whatever i want but the problem is this doesnt seem to execute
});
});
</script>
<form id="propertysearch" action="/search" method="GET">
<p>
<select id="maxprice" name="maxprice" style="width:47%;">
<option value="10000000">Max Price...</option>
<option disabled="disabled" value="10000000">- - - - - - - - - - - - - - - - - - - - - - -</option>
<br />
<option value="100000">?100,000</option>
<option value="150000">?150,000</option>
<option value="200000">?200,000</option>
<option value="250000">?250,000</option>
</select></p>
<p><a href="javascript:document.forms['propertysearch'].submit();" title="Find a Property">Find a Property Now</a> ></p>
</form>
Any help would be appreciated!
UPDATE I have now got the code to work by using <input type="submit" value="Submit"> instead of <a href="javascript:document.forms['propertysearch'].submit();" title="Find a Property">Find a Property Now</a>
so how can I change this my <a></a> to make it work
Thanks for your help