Actions

API15

JHTMLSelect/integerlist

From Joomla! Documentation

< API15:JHTMLSelect
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Generates a select list of integers

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

integerlist($start, $end, $inc, $name, $attribs=null, $selected=null, $format="")
Parameter Name Default Value Description
$start The start integer
$end The end integer
$inc The increment
$name The value of the HTML name attribute
$attribs null Additional HTML attributes for the <select> tag
$selected null The key that is selected
$format "" The printf format to be applied to the number

Returns

string HTML for the select list

Defined in

libraries/joomla/html/html/select.php

Importing

jimport( 'joomla.html.html.select' );

Source Body

function integerlist( $start, $end, $inc, $name, $attribs = null, $selected = null, $format = "" )
{
        $start  = intval( $start );
        $end    = intval( $end );
        $inc    = intval( $inc );
        $arr    = array();
 
        for ($i=$start; $i <= $end; $i+=$inc)
        {
                $fi = $format ? sprintf( "$format", $i ) : "$i";
                $arr[] = JHTML::_('select.option',  $fi, $fi );
        }
 
        return JHTML::_('select.genericlist',   $arr, $name, $attribs, 'value', 'text', $selected );
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />