CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 How to Count ListBox values

Print topic Send  topic

Author Message
gingercat

Posts: 48
Posted: 10/06/2010, 8:18 PM

I have a list box used as a search for a standard grid. The option values are populated from a SQL query. I want to be able to check the number of values and if they're less than 3 make the whole search from invisible.

I have working code that's no problem but the part I cant' work out is how to find out how many option values are actually in the list box
View profile  Send private message
datadoit
Posted: 10/07/2010, 5:43 AM

Since the listbox values are pulled via SQL, then include in your query
SELECT COUNT(keyfield) AS Count, blah blah blah. In the listbox's
BeforeShow you can test for that value.

if ($Component->ds->f("Count") > 3) {
Do this;
}
gingercat

Posts: 48
Posted: 10/08/2010, 2:29 PM

In theory the following should work in the BeforeShow event:

if ($FormSearch->s_phone->DataSource->RecordsCount < 3) {
$FormSearch->Visible = false;
}
else $FormSearch->Visible = true;

but RecordsCount always returns 0 - any ideas why?

what does the f method mean in your above example - It doens't comeu p as an autocomplete for me

I'm using MSSQL and never did get the above SQL to work
View profile  Send private message
CodeChargeMVP

Posts: 473
Posted: 10/11/2010, 10:06 AM

I donīt know if this would be helpful,

but on javascript the listbox object has a property called length,

so that you can retrieve the number of options available this way:

option_numbers = document.forms["yourform"].elements["yourobjectelementlistbox"].length;

or

option_numbers = window.document.getelementById("youridobjectlistbox").length;


Iīd concern about than the BeforeShow event is no the right event because maybe

as it says on before show, maybe the form values hasnīt been retrieved yet,so thatīs

maybe why the property returns all the time 0.

Iīd check the help from CSS and see which event would fix.


Quote gingercat:
In theory the following should work in the BeforeShow event:

if ($FormSearch->s_phone->DataSource->RecordsCount < 3) {
$FormSearch->Visible = false;
}
else $FormSearch->Visible = true;

but RecordsCount always returns 0 - any ideas why?

what does the f method mean in your above example - It doens't comeu p as an autocomplete for me

I'm using MSSQL and never did get the above SQL to work

_________________
Best Regards
Entrepeneur | NT Consultant
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.

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.