Edit Options for Select

QuestionsEdit Options for Select
John Godish asked 11 years ago

Can/How do you get the edit options for edit type "Select" from a data base instead of hard coding?

3 Answers
Abu Ghufran answered 11 years ago

Please refer dropdown.php. It has working sample with db driven lookup control.

Bill answered 11 years ago

John — Here's how I did it:

// Edit options declaration in "Select" column:
$Col['editoptions'] = array('value'=>$Db->CodeOptions('ROWSTATUS'));

// Function to fill the select options:
public function CodeOptions($CodeType) {
$CodeType = strtoupper(trim($CodeType));
$Options = '';
$Result = $this->SQLSelect('select CodeValue, Description
from wb_code
where CodeType = "' . $CodeType . '" and RowStatusID = 1
order by CodeValue');
while ($Row = mysql_fetch_assoc($Result)) {
$Options .= $Row['CodeValue'] . ':' . $Row['Description'] . ';';
}
// Drop the last semicolon.
$Options = substr($Options, 0, strlen($Options) – 1);
// Return string something like "1:Active;2:Inactive;3:Deceased"
return($Options);
}

Hope this helps!

Bill answered 11 years ago

Sorry…my indentations didn't work in the above example.

Your Answer

2 + 6 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?