|
|
|
|
|
|
| |
| <?php
class Combo
{
var $label;
var $index;
var $value;
var $description;
function Combo ()
{
$this->label = "Select an option: ";
$this->index = -1;
$this->value = "";
$this->description = "";
}
function addItem ($value, $description)
{
$this->index++;
$this->value[$this->index] = $value;
$this->description[$this->index] = $description;
}
function clear()
{
$this->Combo();
}
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> | | |
|
| Vote-Poll script that has a wrapper class that allows the user to create
multiple polls on the same page with little trouble. Categories : PHP, PHP Classes, HTML and PHP | | | Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but
effective. Categories : PHP, PHP Classes, HTML, HTML and PHP | | | class formHTML build your HTML Forms from PHP Categories : PHP, PHP Classes, HTML and PHP, HTML | | | Customizable Calendar Class Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar | | | XTemplate, a template class for PHP Categories : PHP Classes, HTML and PHP, PHP | | | A script to generate a report from a valid mysql connection. The user has to supply which fields he wants to display in table. All properties are changable.
Categories : PHP, PHP Classes, Databases, MySQL, HTML and PHP | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | A simple class with some HTML output functions that would come in handy for consistent page layout etc. Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation | | | phpFormGenerator for Dynamic Form Generation from MySQL Categories : PHP, PHP Classes, MySQL, Databases, HTML and PHP | | | Simple class to build tables with style sheets Categories : HTML and PHP, PHP Classes, PHP | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Authorize.net AIM Interface Class v1.0.0 Categories : PHP, PHP Classes, Ecommerce, Payment Gateways | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | |
| | | | 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
| |
|
|
|