Skip to content Skip to sidebar Skip to footer

How To Change Form Url Parameter On Submit?

I have this form for processing..

Solution 1:

jQuery

$('button[type=submit]').click(function(e){
    e.preventDefault();
    e.stopPropagation();

    window.location = "http://sites.com/driver/" + $('#search').val();

    returnfalse;
});

or

$('form').submit(function(e) { // you really need to class/ID your form// all that code
});

Now this is quick and dirty to give you the idea. You'd of course want to sanitize your input (good idea to do that on the front-end as well as the back-end).

Solution 2:

You will have to handle form submit event yourself. Something like this:

document.querySelector('form').addEventListener('submit', function(e) {
    e.preventDefault();
    location.href = '/driver/' + this.elements.n.value;
}, false);

Post a Comment for "How To Change Form Url Parameter On Submit?"