feha
Posts: 712
|
Posted: 01/29/2006, 5:09 PM |
|
I have made a radio button in form it enters ok from listofvalues,
now is the question how to get it in label (grid) to display proper (selected) value ?
(integer)
values are:
1;Left;2;Right;3;Top;4;Bottom;;n/a
i can't get option in label to put lost of values ...
thank you in advance
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
magus
Posts: 98
|
Posted: 01/31/2006, 7:19 PM |
|
Hello Feha,
Not sure that I exactly follow your question. Let me summarise what I think you are asking.
You have made a form with the radio buttons and it works. It saves the data. Now in a grid you want to display the equivalent text value of the data using a label. Is this correct?
If so, you might try the label beforeshow event to switch/case test and set the component value to the appropriate text. However, you do need to set the Datas Type to "Text" not "Integer".
switch ($Component->GetValue()) {
case 1:
$Component->SetValue('Left');
break;
case 2:
$Component->SetValue('Right');
break;
case 3:
$Component->SetValue('Top');
break;
case 4:
$Component->SetValue('Bottom');
break;
case "":
$Component->SetValue('n/a');
break;
}
Sorry if I didn't understand your question correctly.
Regards,
Don A
|
|
|
feha
Posts: 712
|
Posted: 01/31/2006, 10:33 PM |
|
Hi Don
Thank You , yes you understand my question ...
but yhis solution is very basic and hard-coded ...
Need something to read from an global array ...
type for each key etc ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
feha
Posts: 712
|
Posted: 01/31/2006, 10:36 PM |
|
this should be built in even for label the List Of Values ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
magus
Posts: 98
|
Posted: 02/01/2006, 5:45 AM |
|
Hi Feha,
I often put the list of component options in a table rather than hardcode a list of values.
Once you have options stored somewhere it should be a straight forward task to generalise the conversion from integer value to text.
Perhaps write a generalised conversion function/s that queries for the available options then changes the label value. The function could create the global array the first time it is called then read it thereafter.
Insert this in Common.php or wherever you put your custom functions. Then call the function with whatever parameters in the before show event.
Feha, from your other posts I know you are pretty smart so I expect you will figure out a better way than I can suggest. :)
Cheers,
Don A
|
|
|
feha
Posts: 712
|
Posted: 02/01/2006, 6:00 AM |
|
Hi Don
Quote :
Perhaps write a generalised conversion function/s that queries for the available options then changes the label value. The function could create the global array the first time it is called then read it thereafter.
This is what i think about ...
I'm too lazy make a table for selections not using more in than one form.
But i still think this should be a feture in CCS as it is to insert for radiobuttons, listbox, checkboxes etc ...
Than it should offer an option List Of Values for label too.
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
feha
Posts: 712
|
Posted: 02/01/2006, 6:57 AM |
|
Here e Go
I'm not lazzy to make a function
function find_ListOfValues($ListOfValues, $compare="3")
{
// by www.vision.to
while(list($key,$value)=each($ListOfValues))
{
if($key == $compare)
return $value;
}
}
$ListOfValues=array(
"1" => "Left",
"2" => "Right",
"3" => "Top",
"4" => "Bottom",
"" => "n/a"
);
echo find_ListOfValues($ListOfValues, $compare="3")
works great ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
|