checkbox into an array

Questions, tips and tricks and techniques for scripting in Servoy

checkbox into an array

Postby Harry Catharell » Tue May 25, 2010 3:23 pm

Servoy v4.1.4
OS X 10.6.3

Hi all,

I have a need to take multiple values from a checkbox field and create an array and do this over a small foundset of records

I seem to be failing miserably using the following code:
Code: Select all
var v_fs_count = foundset.getSize();
   var v_array_result = new Array();
   var v_array_record = new Array();
   var v_string = null;
   for ( var i = 1 ; i <=v_fs_count ; i++ )
      {
      var v_current = foundset.setSelectedIndex(i);
      v_string = z_temp_column;//checkbox field
      if ( v_string )
      {
      v_array_record = v_string.split(' ');
      v_array_result.concat(v_array_record);
      }
      }


Any pointers to where I may be going wrong appreciated

Cheers
Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Re: checkbox into an array

Postby mboegem » Tue May 25, 2010 4:34 pm

just curious: what other value than just 0 (or nulll) or 1 do you expect the checkbox to hold?

further: you already mentioned it's a small foundset. Mind that this function will fail for foundsets >200 records.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: checkbox into an array

Postby Harjo » Tue May 25, 2010 4:35 pm

try splitting on '\n' instead of " "

Marc, if you have a TEXT field, with text valuelist, a checkbox can return (multiple) text also and they are seperated with a '\n' AFAIK ;-)
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: checkbox into an array

Postby Harry Catharell » Tue May 25, 2010 6:42 pm

Hi Marc

As Harjo mentions, there are multiple options for this checkbox field which is driven by a valuelist of (in this instance) suppliers for a product group
I want to multiselect the suppliers and create an array of their primary keys to cycle through and do something with them
Also, my foundsets are within 10 or so records here so very small and manageable

Hi Harjo,

Thanks, the '\n' worked
All that I need to do is get my .concat() line working as it seems to be ignoring it :-)

Cheers
Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Re: checkbox into an array

Postby Joas » Wed May 26, 2010 1:59 pm

Harry Catharell wrote:All that I need to do is get my .concat() line working as it seems to be ignoring it :-)

That is because concat only returns the concatenation, it doesn't change the original.

To get it working you should do this:
Code: Select all
v_array_result = v_array_result.concat(v_array_record);
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: checkbox into an array

Postby martinh » Mon Jul 05, 2010 10:44 am

It works, but the multiple values are displayed in a horizontal way.
I would like to see the multiple values in a vertical way, and when there are a lot of values, I want to see those in values in multiple columns.
How can that be done?
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium


Return to Methods

Who is online

Users browsing this forum: No registered users and 6 guests