I've solved this issue and i'd like to share what i've done, so it could be helpfull to anyone else.
Executing javascript for a button in an specific row on the list page.
We need to identify the button as unique so i add an alias in the sql query editor adding this:
SELECT
b_cabin_agenda.id_cabage,
b_cabin_agenda.estado,
0 AS ac_estado,
FROM b_cabin_agenda
Note that id_cabage is the index in that table
Then in the fields page, only select ac_estado field to be shown in the list page.
In the visual editor, in the custom view of the field ac_estado, i add this code
$value = "<input type=\"button\" name=\"activar\" value=\"Activar disponible\" id=\"".$data['id_cabage']."\" />";
That way, each button will have an unique id taken from the id_cabage field.
I also, in same page, add an id for other field, in this case estado, to make some modify actions after click be done
if ($value =="DISPONIBLE") {
$color="black";
} else {
$color="red";
}
$value= "<span style='color:".$color."' id=\"est".$data['id_cabage']."\"> ".$value." </span>";
Then in the event page, i'll add in the list page, on the JavaScript OnLoad evet what follows:
$("input[type='button'][name='activar']").click(function(e){
//in next line i save the id of the button in var named mide
var mide = $(this).attr('id');
//i make a call using jquery ajax to an external file added to projectfolder/source folder, named funciones2m.php
$.ajax({
type: "POST", //we use POST method, important for the external php file
url: "funciones2m.php", //php file is indicated
//send 2 paramethers, funcion indicates function to be executed, and mide has the id to be updated, same of index, same of button
data: "funcion=b_cabage_list_activa&id="+mide,
//if everything worked as it should, we execute a function on client side
success: function(msg){
$("#est"+mide).html(msg); // shows what php file shows as an echo
$("#est"+mide).css("color","black"); //we change font color for another field in the same "mide" record, for example
}
});
});
Finnaly, the code for the funciones2m.php file, i store all the functions i want, and using switch selector, i use the independently one from another. This way i don't need to be uploading too many different files.
<?php
switch ($_POST["funcion"]) {
case "b_cabage_list_activa":
//actualiza el estado para el id que se le pasa
$con=mysql_connect("localhost","idsrdcom_ucab","lapassdecab");
$bd=mysql_select_db("idsrdcom_cab",$con);
$sql="update b_cabin_agenda set estado='DISPONIBLE' where id_cabage=" .$_POST["id"]." and estado=''";
$res=mysql_query($sql,$con);
//extrae el estado del registro editado
$sql1="select estado from b_cabin_agenda where id_cabage=".$_POST["id"]." and id_cabage > 1";
$res1=mysql_query($sql1,$con);
$reg1=mysql_fetch_array($res1);
echo $reg1["estado"];
break;
case "other_funcion":
//do whatever
break;
case "someother_funcion":
//do whatever
break;
}
?>
I'm not a programmer and i maked what i needed, PHPr is grate, thanks xlinesoft team.
Hope this topic be help for someone.