Page 1 of 1

DropDown with default?!?

Posted: Sat Mar 13, 2010 5:47 pm
by jmansa
I'm wandering how to make a dropdown list from db with one specific record as default.

Im getting the data like this:

Code: Select all

$pricelist = array();
    $q = "SELECT * FROM ".cms_db_prefix()."module_sms_prices WHERE product = $product_id ORDER BY price ASC";
    $dbresult = $db->Execute( $q );
    if( $dbresult ) {
    while( $row = $dbresult->FetchRow() )
      {
	$pricelist['kr. '.$row['price'].',-'] = $row['id'];
      }
    }
	
	$this->smarty->assign('pricelist_input', $this->CreateInputDropDown( $id, 'price', $pricelist, -1));
This part works fine but in my db I have a field called "active" and one is set to "1". How do I make that certain record selected as default???

Hope somebody can understand this and thanks in advance...

Re: DropDown with default?!?

Posted: Sat Mar 13, 2010 8:43 pm
by Peciura
How do I make that certain record selected as default???
http://www.cmsmadesimple.org/apidoc/

To be more precise
http://www.cmsmadesimple.org/apidoc/CMS ... utDropdown

Re: DropDown with default?!?

Posted: Sat Mar 13, 2010 10:46 pm
by jmansa
Not sure how and which parameter sets the selected...

Re: DropDown with default?!?

Posted: Sat Mar 13, 2010 11:50 pm
by Peciura
It is a copy from Products module "function.admin_prefstab.php" file.
Variable $sortorder contains value that should be selected from available options.
$sortorders = array(
   $this->Lang('ascending')=>'asc',
   $this->Lang('descending')=>'desc
');
$smarty->assign('input_summarysortorder',
  $this->CreateInputDropdown($id,'sortorder',$sortorders,-1,$sortorder));