Hi All,
I'm trying to submit a form to a different location depending on which (of two) form fields have been filed in.
It work when both fields have a value but when only one if field has a value it always submits to the suppliers/category/ URL. Here is my code.
$('#suppliersForm').submit(function() {
catVal = $('#category').val()
keywordVal = $('#keywords').val()
if( $('#category').val() && $('#keywords').val() )
{
var searchString = 'http://<cfoutput>#cgi.server_name#</cfoutput>/suppliers/searchresults/' + catVal + '/' + keywordVal
window.location.replace(searchString);
}
else if( $('#category').val() || $('#keywords').val() )
{
var searchString = 'http://<cfoutput>#cgi.server_name#</cfoutput>/suppliers/category/' + catVal
window.location.replace(searchString);
}
else if( $('#keywords').val() || $('#category').val() )
{
var searchString = 'http://<cfoutput>#cgi.server_name#</cfoutput>/suppliers/keywords/' + keywordVal
window.location.replace(searchString);
}
return false;
});
Any help would be appreciated