CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Multiple Select Listbox

Print topic Send  topic

Author Message
bburnett

Posts: 22
Posted: 02/12/2004, 12:03 PM

I wanted store the selected values from a multiple choice listbox into a databse field (as the comma delimited list that HTML forms post natively). And correctly highlight the selected values in the listbox when the user returns to edit the record. I have done this before with ASP and CCS2. PHP version for some reason only returns the first value.

I ended up needing to modify 2 sections of clsControl in Classes.php:

This is the modified clsControl GetValue() function:

function GetValue()
{
if($this->ControlType == ccsCheckBox)
$value = ($this->Value) ? $this->CheckedValue : $this->UncheckedValue;
else if($this->Multiple && is_array($this->Value)){
//$value = $this->Value[0];
$strValues="";
foreach ($this->Value as $col_value) {
$strValues=$strValues.$col_value.",";
}
$strValues=substr($strValues, 0, Strlen($strValues)-1);
$value = $strValues;
}
else
$value = $this->Value;

return $value;
}

This is the modified case ccsListbox statement in the Show function:

case ccsListBox:
$Options = "";
if(is_array($this->Values))
{
//2-12-04 Brandon Burnett Added this if clause because this->value isn't treated as an array without it
if($this->Multiple){
$this->Value = explode(",",$this->Value);
}
for($i = 0; $i < sizeof($this->Values); $i++)
{
$Value = $this->Values[$i][0];
$TextValue = htmlspecialchars(CCFormatValue($Value, $this->Format, $this->DataType));
$Text = htmlspecialchars($this->Values[$i][1]);
if($this->Multiple && is_array($this->Value)) {
$Selected = "";
for($j = 0; $j < sizeof($this->Value); $j++){
if($Value == $this->Value[$j]){
$Selected = " SELECTED";
}
}
}
else {
$Selected = ($Value == $this->Value) ? " SELECTED" : "";
}
$Options .= "<OPTION VALUE=\"" . $TextValue . "\"" . $Selected . ">" . $Text . "</OPTION>\n";
}
}
$Tpl->SetVar($this->Name . "_Options", $Options);
$Tpl->ParseSafe($this->BlockName, false);
break;



_________________
Brandon Burnett
New Media Architect
REL Productions
West Des Moines, IA, USA
www.relonline.com
View profile  Send private message
peterr


Posts: 5971
Posted: 02/12/2004, 2:44 PM

We have related example in CCS Example Pack: "Updating Many-to-Many via CheckBox List".
This works without any modifications to common files.

The data in our example is stored little differently but this shouldn't matter.

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Ramu
Posted: 07/16/2004, 6:21 AM

:( boss.. your solutions are not very complete..I would suggest... that you change this functionality asap... I suppose... you should have a function on the micro level to handle HTML Arrays... and list boxes..I am haveing a lot of trouble..cause..of that.
sweiss

Posts: 22
Posted: 08/18/2004, 12:14 AM

Hi,

when will this be fixed? The "Updating Many-to-Many via CheckBox List" is not really a solution!

Regards

Stefan
View profile  Send private message
peterr


Posts: 5971
Posted: 08/18/2004, 12:18 AM

Please specify how you would you like this to be "fixed", and submit a detailed suggestion to our Support, or the Wishes forum.

Thanks
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
sweiss

Posts: 22
Posted: 08/18/2004, 3:57 AM

See the posting from Ramu. If we use it like the example we have to write a lot of code and i think Codecharge Studio is a code generator

Regards

Stefan
View profile  Send private message
peterr


Posts: 5971
Posted: 08/18/2004, 4:08 AM

Stefan,

OK... but I don't know which method Ramu would like to use. And I don't know if his method would be the one desired by most people, or if it even makes sense.
We already have good experience and we know that there are several ways of handling multi-select data & many-to many relations.
The main reason that multi-select Listbox wasn't automated yet is that there are too many variables and everyone may want to handle it differently.
BTW, storing such data in comma-delimited field is one of the less common methods to handle this. We specifically didn't want to do this because we don't want to suggest such method to the users.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
sweiss

Posts: 22
Posted: 08/18/2004, 10:14 PM

Peter,

yes, i see it as you describe it but i think if you give us a one solution - as it is, for example we need a table where the relations for a multiple listbox are stored, like the example "Multiple Listbox" we would save a lot of time.

I don't believe that you have to support all ways of handling this, i think one defined solution is enough and i think this is a way where we all can live with it.

Greetings from Munich, Germany

Stefan
View profile  Send private message
peterr


Posts: 5971
Posted: 08/18/2004, 10:29 PM

OK. I'll "push" for implemeting some proper solution :-)
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
sweiss

Posts: 22
Posted: 08/18/2004, 11:32 PM

Thanks for your fast reply

Stefan
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.