CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> Archive -> GotoCode Archive

 Default value for listbox based on query...

Print topic Send  topic

Author Message
Xav
Posted: 01/27/2003, 6:09 PM

Hi there,

I am having problems with a list box which lists items found in a categories table. This is the standard catID, name, parentCatID setup. I have a listbox based on a query which lists the category name for the corresponding parentCategory field. I have two special cases in the table. Entries with a parentCategoryID of 0 and -1. These correspond to two different top level entities.

When the form loads, items that do not have a -1 or 0 for parentCategoryID, that is items with parentCategoryID = 1,2,3 etc, the name in the listbox is displayed correctly.

Yet for items that do have 0 or -1 it defaults to one value. This is due to me specifying the values to include for the "select" properties on the HTML tab. This is on an update style form, so if I click update it effectively switches the value over for me.

Obviously the 0 and -1 entries are pulled from the DB correctly, so is there a way I can programatically set the listbox to default to the correct value based on these cases?

Regards,

Xav
RonB
Posted: 01/28/2003, 1:56 AM

I take it the type for the id is set to int, try setting it to text. MySql will still transform it to a int if the text string holds a valid int value.

Ron
Xav
Posted: 01/28/2003, 3:17 PM

Ron,

You mean change the type of the listbox to text???

Xav
RonB
Posted: 01/29/2003, 7:04 AM

sorry for the delayed response but your question turned out ot be more intrigueing then I thought. The problem as I understand it is that you want to change the value shown in the dropdown if the boundcolumn value is 0 or -1.
I've tried to get how CCS deals with getting a dropdown list and that's pretty straight forward. The problem is I cant figure out how to acces the values before the list is passed to the page.

Let's say the dropdown list is called employee with emp_id as boundcolumn and emp_name as textcolumn. CCS initiates a new clsControl and uses the sqlstatment to fill an array. The array containes the pair values of emp_id<->emp_name and is used to fill the dropdownlist.

The documentation of classes and objects is terrible so I'll show you what I was thinkng of but didn't get to work:

There are two methods that can be used with lists :Getvalue() for the boundcolumn and GetText for the textcolumn and their counterparts SetValue() and SetText(). I'm having trouble with finding out wether the list as a control is part of the recordset or an object on itself.
I tried a beforeshowevent that looked like this:

global $gridname;
if($gridname->controlname->BounColumn->GetValue() == 1)
{
$gridname->controlname->TextColumn->SetValue("test")
}

I get no errors but the textvalue for the id 1 isn't changed.

It probably has to do with how and in what stage you try to acces the object but I can't find any reference on that in the documentation and I'm not
(yet :-) that fluent in CCS OOP.

Maybe you can do something with all this info or maybe someone that better understands the way CCS handles these thing could give us a tip. I hate it when I'm intrigued and don't get any further so I'd like to know the answer to this one myself (even if I cant think of any circumstance where I'd want to use this :-)

Ron

Xav
Posted: 01/29/2003, 5:03 PM

Ron,

Thanks for going to so much trouble! I just thought I'd post my problem here to see if anyone had come across it and can point me in the right direction. I hadn't really looked too much into it. As it is, if I remember to just select the correct value in the listbox before I do an update, all is OK, as I know that I have to do that. In terms of "bullet proofing" it though from a general user's perspective this isn't so good.

Really, I should seperate the data into two mysql tables - i.e. normalise them. I am using the categoryParentID field set to -1 to indicate that this is an image category and 0 means it is a text category. Then when using the CCS directory builder, I can effectively display two different directories based on the root entity ID. Try it, it works nicely. The problem is as stated updating them. The best way would probably just be split the table into two seperate categories table and rebuild the directory pages. Yet this does sacrifice updating all categories from a single form submission...

If you want a more interesting problem, see my main post about FULLTEXT searches....

Regards,

Xav.

   


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

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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