New question

Question:

Date: 31-01-2019 09:44:03 (In Spanish)

Create url with checkbox values[Unresolved]

I have a form with ckeckbox's that gets values (value) from a url csv (through a for). I need that when I click on the submit button the browser sends me to a url that contains the value of the selected checkbox.
<form name="sensores" method="post">
<small id="instruccion">Elige la(s) variable(s) a filtrar:</small>
<?php
$file_dir = "http://www.url.com/csv";

if(($file = fopen($file_dir,"r")) !== FALSE){
        while (($recordset = fgetcsv($file,0,","))!== FALSE){
        $columns = count($recordset);
            for($i = 6 ; $i < $columns ; $i++){
              ?>
<div>
    <input type="checkbox" id="<?php echo $recordset[2]?>" name="opcion" value="<?php echo $recordset[1];?>">
    <label id="<?php echo $recordset[2]?>"><?php echo $recordset[2]."<br>";?></label>
</div>
<?php
            }
        }
}else{
    echo "Error";
}
?>
<button name="submit" type="submit" value="submit">Generar URL</button>
</form>
Tags: Array PHP - Form - PHP - Script PHP Votes: 0 - Answers: 1 - Views: 7 Share on: Google Facebook Twitter LinkedIn Link
 

Answers:

  •  
      0  
     
    Date: 31-01-2019 13:03:37 Hola.
    Utilizas JQuery ?
    el formato de las url que recibes como es?
    el formulario debe llevarte datos o solo quieres redireccionar?
    en los chekbox siempre se va a seleccionar uno solo ?, en caso que se la seleccion sea multiple, a cual de las rutas deberia ir ?

    Yo utilizaria Jquery, agregandole una clase a los checkbox, y despues capturaria el evento del check y le pasaria el valor de su url al action del form o al boton, dependiendo de la necesidad, una vez que haces eso el form se iria a donde le pasaste la url.

    Saludos
      Votes: 0 - Link answer
     
To actively participate in the community first must authenticate, enter the system.Sign In
 
frjcbbae garagebible.com