I have write a code to create a select with PHP Object which is:
<?php
class Modulo {
var $nD;
var $nC;
var $nA;
function __construct($nD,$nC,$nA) {
$this->nD=$nD;
$this->nC=$nC;
$this->nA=$nA;
}
function toString(){
return $this->nD."-".$this->nC."-".$this->nA."<br>";
}
}
?>
Here is the method to build the select:
function loadModuleValid(){
$mod1 = new Modulo(4,3,3);
$mod2 = new Modulo(5,3,2);
$mod3 = new Modulo(4,4,2);
$mod4 = new Modulo(5,4,1);
$mod5 = new Modulo(4,5,1);
$mod6 = new Modulo(3,5,2);
$mod7 = new Modulo(3,4,3);
$mods = array($mod1,$mod2,$mod3,$mod4,$mod5,$mod6,$mod7);
$i = 0;
print "<h3>Seleziona il modulo</h3>";
print "<select id=\"d1\">";
foreach ($mods as $key ) {
print "<option value=\"{$i}\">{$key->toString()}</option>";
$i++;
}
print "</select>";
}
Now I have to retrive the selected object by the user when the she/he presses a button. How can I do ? I want the actual object not just it's value !