function display ($name, $subnit)
{
if ($this->index<0)
{
echo "";
}
else
{
echo $this->label . "<select name=\"$name\" ";
if ($subnit!="") echo " OnSubmit=\"$subnit\" ";
//if you want to use some other event just add it in this function
echo ">\r"; // the \r is only for a clear html coding...
for ($x=0;$x<$this->index+1;$x++)
{
echo "<option value=\"" . $this->value[$x] . "\">" . $this->description
[$x] . "</option>\r";
}
echo "</select>\r";
}
}
}// End Class
?>
<form>
<?
$cmb = new Combo;
$cmb->addItem("A","Opci");
$cmb->addItem("B","Opci");
$cmb->addItem("C","Opci");
$cmb->display("letras","gotoLetras(this);");
$cmb->clear();
$cmb->label = "Choose a number"; //Chamging the label
$cmb->addItem("1","Opci");
$cmb->addItem("2","Opci");
$cmb->addItem("3","Opci");
$cmb->display("N?s","gotoNumeros(this);");
?>
</form>
David Perez wrote :870
some changes in the function display
function display ($name, $selected, $subnit)
{
if ($this->index<0)
{
echo "";
}
else
{
echo $this->label . "<select name=\"$name\" ";
if ($subnit!="") echo " OnSubmit=\"$subnit\" ";
//if you want to use some other event just add it in this function
echo ">\r"; // the \r is only for a clear html coding...
for ($x=0;$x<$this->index+1;$x++)
{
echo "<option value=\"" . $this->value[$x] . "\"";
if ($selected==$this->value[$x]) echo " selected ";
echo ">" . $this->description[$x] . "</option>\r";
}
echo "</select>\r";
}
}
and now should be called like...
$cmb->display("Nmeros","2","gotoNumeros(this);");
this change is for select one option by default