Form landing page via GET with custom link

0

I have a form that sends data via GET , forwarding the data to the page busca2.php , as shown below:

<form action = "busca2.php" method = "GET" id="formulario">

When submitting the form, the link is as follows:

busca2.php?campo1=x&campo2=y&campo3=z(e etc)

I'm trying to pass this link to a friendly url. I already know how to implement the commands inside the htaccess file. My question is to submit the form directly to the url already customized, for type:

busca/14/16/17/18(e etc)

How do I proceed?

Anyway, thanks to everyone.

    
asked by anonymous 11.07.2016 / 22:41

1 answer

0

Well, I imagine a function in javascript to solve this.

<script>
function enviaDados(){

    var campos = [
        document.getElementById('campo1').value,
        document.getElementById('campo2').value,
        document.getElementById('campo3').value
    ]

    campos = campos.join('/');

    window.location='/busca/' + campos;

    return false;
}
</script>


<form action="" method="GET" id="formulario" onsubmit="return enviaDados();">
    <input type="text" id="campo1" value="11" />
    <input type="text" id="campo2" value="2222" />
    <input type="text" id="campo3" value="33333" />
    <input type="submit" value="enviar" />
</form>
    
11.07.2016 / 22:56