Form destination page via GET with custom link

Asked

Viewed 93 times

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 am wanting to pass this link to url friendly. I already know how to implement the commands inside the file htaccess. My question is to submit the form directly to the already customized url, for type:

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

How should I proceed?

Anyway, thank you all.

1 answer

0

Well, I imagine a javascript function 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>
  • Hello, Givanildo. I will do the test and soon return with the result obtained. Thank you.

  • 1

    Okay Givanildo , gave it right. thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.