Re: My little update to HTML_OPTIONS

From: Date: Thu, 20 Sep 2001 23:24:43 +0000
Subject: Re: My little update to HTML_OPTIONS
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1500@lists.php.net to get a copy of this message
I think the accepted XML syntax for things that were formerly just a key word looks like: <option value="foo" selected="selected"> see http://www.w3.org/TR/xhtml1/#h-4.5 ----- Original Message ----- From: "Monte Ohrt" <monte@ispi.net> To: <smarty@lists.ispi.net> Cc: <smarty@lists.ispi.net> Sent: Thursday, September 20, 2001 11:50 AM Subject: [smarty] Re: My little update to HTML_OPTIONS > Is this syntax compatible with all browsers? > > LIMBOURG Arnaud wrote: > > > > Hello, > > > > For those of you who are interested, here is my little update to the > > html_options functions to make it more XHTML compliant. The change is just > > on the <option value="foo" selected="foo"> instead of <option value="foo" > > selected> > > > > I cannot put these anywhere else since my firewall blocks everything. > > > > Arnaud. > > > > /*======================================================================*\ > > Function: smarty_func_html_options > > Purpose: Prints the list of <option> tags generated from > > the passed parameters > > \*======================================================================*/ > > function smarty_func_html_options() > > { > > $print_result = true; > > > > extract(func_get_arg(0)); > > > > $html_result = ""; > > > > settype($selected, 'array'); > > if (isset($options)) { > > settype($options, 'array'); > > foreach ($options as $key => $value) { > > $html_result .= "<option value=\"$key\""; > > if (in_array($key, $selected)) > > $html_result .= " selected=\"$key\""; > > $html_result .= ">$value</option>\n"; > > } > > } else { > > settype($output, 'array'); > > settype($values, 'array'); > > for ($i = 0; $i < count($output); $i++) { > > /* By default, check value against $selected */ > > $sel_check = $values[$i]; > > $html_result .= '<option'; > > if ($i < count($values)) > > $html_result .= ' value="'.$values[$i].'"'; > > else > > $sel_check = $output[$i]; /* if more outputs than > > values, then > > check output against > > $selected */ > > if (in_array($sel_check, $selected)) > > $html_result .= " selected=\"$key\""; > > $html_result .= '>'.$output[$i]."</option>\n"; > > } > > } > > > > if ($print_result) > > print $html_result; > > else > > return $html_result; > > } > > > > --- > > You are currently subscribed to smarty as: monte@ispi.net > > To unsubscribe send a blank email to $subst('Email.Unsub') > > Visit Smarty's homepage at > > http://www.phpinsider.com/php/code/Smarty/ > > -- > Monte Ohrt <monte@ispi.net> > http://www.ispi.net/ > > --- > You are currently subscribed to smarty as: sweatjejm@home.com > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ >

« previous php.smarty.general (#1500) next »