<form action="" id="form" method="POST" >
<select id="controlselect" name="ordenar">
<option value='0' >Seleccione</option>
<option value='1' >General</option>
<option value='2' >Producto</option>
</select>
<input type="submit" id="BotonBuscar" onclick="Buscar()" value="buscar" />
<input type="submit" id="BotonGenerar" onclick="Generar()" value="generar" />
</form>
I have the following form, with its combobox and two buttons.
1.1 I want that when the user presses the Search button it sends the select elements to my Test 8 php file and when they press the Generate button it sends the select elements to my Test 9 file.
1.2 I've been searching, but I can't find the solution, I'm implementing JavaScript code to manipulate the form and its action property and I have something like this but it doesn't work.
function Buscar()
{
document.getElementById('BotonBuscar').addEventListener('click', (e) => {
e.preventDefault()
form.setAttribute("action", "Prueba8.php")
})
}
function Generar()
{
document.getElementById('BotonGenerar').addEventListener('click', (e) => {
e.preventDefault()
form.setAttribute("action", "Prueba9.php")
})
}
1.3 Is it possible to do this manipulation? If so, then can you provide me with the well-prepared and explained code, based on what I have or some better solution.
Thanks in advance!
I'll leave you comments on the code, do the test and let me know if you have any questions. :D
in PHP