CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 Listbox Blues (with Multiple Selection)

Print topic Send  topic

Author Message
Abidoon Nadeem
Posted: 03/22/2003, 10:34 AM

So far I have found no decent way of storing multiple selected values from a
multiple selection listbox into the database and then retrieving them
i dont think this issue has been addressed in codecharge studio 2.0 as well
can the developers shed some light on this

After a lot of tinkering and with a lot of bad code i was able to get the
multiple selection box to store selected values in the database however no
amount of coaxing will let u update it . because when ever one comes to
change the values in the update mode the values (keys) that were selected
previously are unselected

Abidoon

me
Posted: 03/22/2003, 12:34 PM

Hi,
I am having the same frustration. Are you using PHP? If so what code did
you use to get the listbox values into the table? I'm working on this as
well and will post my solution if I find one.
Thanks,
Walter
"Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
news:b5iabc$lm8$1@news.codecharge.com...
> So far I have found no decent way of storing multiple selected values from
a
> multiple selection listbox into the database and then retrieving them
> i dont think this issue has been addressed in codecharge studio 2.0 as
well
> can the developers shed some light on this
>
> After a lot of tinkering and with a lot of bad code i was able to get the
> multiple selection box to store selected values in the database however no
> amount of coaxing will let u update it . because when ever one comes to
> change the values in the update mode the values (keys) that were selected
> previously are unselected
>
> Abidoon
>
>

Abidoon Nadeem
Posted: 03/23/2003, 10:53 AM

i have found a complete solution
i mean i have made pages to cater a scenario
where one can select multiple values in the list box and after pressing
submit the database is updated
additionally if i come back to the same record only those values are
selected that were stored in the database
but i had to do the whole thing by hand !
i mean no codecharege studio was involved
i made the whole thing by hand !

"me" <beach4300@earthlink.net> wrote in message
news:b5ihd9$549$1@news.codecharge.com...
> Hi,
> I am having the same frustration. Are you using PHP? If so what code did
> you use to get the listbox values into the table? I'm working on this as
> well and will post my solution if I find one.
> Thanks,
> Walter
> "Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
>news:b5iabc$lm8$1@news.codecharge.com...
> > So far I have found no decent way of storing multiple selected values
from
> a
> > multiple selection listbox into the database and then retrieving them
> > i dont think this issue has been addressed in codecharge studio 2.0 as
> well
> > can the developers shed some light on this
> >
> > After a lot of tinkering and with a lot of bad code i was able to get
the
> > multiple selection box to store selected values in the database however
no
> > amount of coaxing will let u update it . because when ever one comes to
> > change the values in the update mode the values (keys) that were
selected
> > previously are unselected
> >
> > Abidoon
> >
> >
>
>

DAVID
Posted: 03/24/2003, 2:15 PM

I had brought this issue to Yes support in the past.
The following is the reply of a support engineer:

David,
This behavior is normal by design because in spite of number of items
selected from such listbox only the last value will be added to db.
The data to store in the table is retrieved sequentially from the parameter
string. All the items selected from the listbox are stored in it too, but
all of them have the same name, e.g.:
listbox1=item1&listbox1=item3&listbox1=item5

In case you want to store all the selected values in one (or may be several)
field or implement search it requires custom code. Please refer to the
GotoCode article "Creating multiple-selection listboxes in CCS" at
http://gotocode.com/art.asp?art_id=201&
In addition to it I emailed you sample CCS project that demonstrates the
multiple selection functionality. It includes PHP events but I hope it would
be helpful anyway. Use sample Intranet DB to test it.

Regards,
Helen



Later on I had to comeup with a set of JavaScript functions that
1. Convert a delimited string sourced in the database into a multiple
select.
2. Upon a modification in select rebuild the delimited string.
and
3. Upon submit, submit the delimited string back to the database.


"Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
news:b5kvr9$e74$1@news.codecharge.com...
> i have found a complete solution
> i mean i have made pages to cater a scenario
> where one can select multiple values in the list box and after pressing
> submit the database is updated
> additionally if i come back to the same record only those values are
> selected that were stored in the database
> but i had to do the whole thing by hand !
> i mean no codecharege studio was involved
> i made the whole thing by hand !
>
> "me" <beach4300@earthlink.net> wrote in message
>news:b5ihd9$549$1@news.codecharge.com...
> > Hi,
> > I am having the same frustration. Are you using PHP? If so what code
did
> > you use to get the listbox values into the table? I'm working on this
as
> > well and will post my solution if I find one.
> > Thanks,
> > Walter
> > "Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
> >news:b5iabc$lm8$1@news.codecharge.com...
> > > So far I have found no decent way of storing multiple selected values
> from
> > a
> > > multiple selection listbox into the database and then retrieving them
> > > i dont think this issue has been addressed in codecharge studio 2.0 as
> > well
> > > can the developers shed some light on this
> > >
> > > After a lot of tinkering and with a lot of bad code i was able to get
> the
> > > multiple selection box to store selected values in the database
however
> no
> > > amount of coaxing will let u update it . because when ever one comes
to
> > > change the values in the update mode the values (keys) that were
> selected
> > > previously are unselected
> > >
> > > Abidoon
> > >
> > >
> >
> >
>
>

Kevin
Posted: 03/27/2003, 9:15 AM

What function are you trying to do? Select many users and 'goup' them in a
group? Pick several items and place them in a container? Your concept of
taking several record objects then placing them into a 'textarea' or making
them CSV delimited data doesn't make sense to me.. using a resolution entity
seems to be a working solution to your problem.


"DAVID" <codecharge_newsfeed@stridetech.com> wrote in message
news:b5o02k$47b$1@news.codecharge.com...
> I had brought this issue to Yes support in the past.
> The following is the reply of a support engineer:
>
> David,
> This behavior is normal by design because in spite of number of items
> selected from such listbox only the last value will be added to db.
> The data to store in the table is retrieved sequentially from the
parameter
> string. All the items selected from the listbox are stored in it too, but
> all of them have the same name, e.g.:
> listbox1=item1&listbox1=item3&listbox1=item5
>
> In case you want to store all the selected values in one (or may be
several)
> field or implement search it requires custom code. Please refer to the
> GotoCode article "Creating multiple-selection listboxes in CCS" at
> http://gotocode.com/art.asp?art_id=201&
> In addition to it I emailed you sample CCS project that demonstrates the
> multiple selection functionality. It includes PHP events but I hope it
would
> be helpful anyway. Use sample Intranet DB to test it.
>
> Regards,
> Helen
>
>
>
> Later on I had to comeup with a set of JavaScript functions that
> 1. Convert a delimited string sourced in the database into a multiple
> select.
> 2. Upon a modification in select rebuild the delimited string.
> and
> 3. Upon submit, submit the delimited string back to the database.
>
>
> "Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
>news:b5kvr9$e74$1@news.codecharge.com...
> > i have found a complete solution
> > i mean i have made pages to cater a scenario
> > where one can select multiple values in the list box and after pressing
> > submit the database is updated
> > additionally if i come back to the same record only those values are
> > selected that were stored in the database
> > but i had to do the whole thing by hand !
> > i mean no codecharege studio was involved
> > i made the whole thing by hand !
> >
> > "me" <beach4300@earthlink.net> wrote in message
> >news:b5ihd9$549$1@news.codecharge.com...
> > > Hi,
> > > I am having the same frustration. Are you using PHP? If so what code
> did
> > > you use to get the listbox values into the table? I'm working on this
> as
> > > well and will post my solution if I find one.
> > > Thanks,
> > > Walter
> > > "Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
> > >news:b5iabc$lm8$1@news.codecharge.com...
> > > > So far I have found no decent way of storing multiple selected
values
> > from
> > > a
> > > > multiple selection listbox into the database and then retrieving
them
> > > > i dont think this issue has been addressed in codecharge studio 2.0
as
> > > well
> > > > can the developers shed some light on this
> > > >
> > > > After a lot of tinkering and with a lot of bad code i was able to
get
> > the
> > > > multiple selection box to store selected values in the database
> however
> > no
> > > > amount of coaxing will let u update it . because when ever one comes
> to
> > > > change the values in the update mode the values (keys) that were
> > selected
> > > > previously are unselected
> > > >
> > > > Abidoon
> > > >
> > > >
> > >
> > >
> >
> >
>
>

DAVID
Posted: 03/28/2003, 1:58 PM

Kevin,
I use multiple select in several applications.
You questions, comments are prefixed with a '>' sign.

>What function are you trying to do?
1. Search.
User enters keyword(s) in a search box, and selects multiple categories
of records he wishes to see.
example : keyword='hunting' --------> result set 1300 records
keyword='hunting' , category=['bolt action
rifle','bolt action pistol'] ---------> result set 103 records

> Select many users and 'goup' them in a group?
2. Email list.
User selects multiple email addresses from address book into To: field
and chooses to save a draft of the message in the database.

>Pick several items and place them in a container?
3. Preferences
User subscribes to realtime updates for a subset of active channels
example: channels=['auction posts','auction bids'],
alertlevel='batched notification', batchtype='time', batchthreshold='600
sec'
Application will check the database every 600 seconds
to see if any records have been updated
in channels 'auction posts' or 'auction bids' and
alert the user with a list of updated items.

>Pick several items and place them in a container?
>Your concept of taking several record objects then placing them into a
'textarea'
>or making them CSV delimited data doesn't make sense to me..
4. Access control
Superuer delegates administration privilege to a user, allowing the
end user to manage records in groups A-Z.
example:
username='david',allowed_domains=[''stridetech.com','stepback.com'],accessle
vel='full_access'.
User david in this example will be able to maintain
mailboxes(mail users) and aliases(mailing lists) for
two postfix virtual mail domains, namely
'stridetech.com' and 'stepback.com'




"Kevin" <kangus@acats.com> wrote in message
news:b5vbk0$d48$1@news.codecharge.com...
> What function are you trying to do? Select many users and 'goup' them in a
> group? Pick several items and place them in a container? Your concept of
> taking several record objects then placing them into a 'textarea' or
making
> them CSV delimited data doesn't make sense to me.. using a resolution
entity
> seems to be a working solution to your problem.
>
>
> "DAVID" <codecharge_newsfeed@stridetech.com> wrote in message
>news:b5o02k$47b$1@news.codecharge.com...
> > I had brought this issue to Yes support in the past.
> > The following is the reply of a support engineer:
> >
> > David,
> > This behavior is normal by design because in spite of number of items
> > selected from such listbox only the last value will be added to db.
> > The data to store in the table is retrieved sequentially from the
> parameter
> > string. All the items selected from the listbox are stored in it too,
but
> > all of them have the same name, e.g.:
> > listbox1=item1&listbox1=item3&listbox1=item5
> >
> > In case you want to store all the selected values in one (or may be
> several)
> > field or implement search it requires custom code. Please refer to the
> > GotoCode article "Creating multiple-selection listboxes in CCS" at
> > http://gotocode.com/art.asp?art_id=201&
> > In addition to it I emailed you sample CCS project that demonstrates the
> > multiple selection functionality. It includes PHP events but I hope it
> would
> > be helpful anyway. Use sample Intranet DB to test it.
> >
> > Regards,
> > Helen
> >
> >
> >
> > Later on I had to comeup with a set of JavaScript functions that
> > 1. Convert a delimited string sourced in the database into a multiple
> > select.
> > 2. Upon a modification in select rebuild the delimited string.
> > and
> > 3. Upon submit, submit the delimited string back to the database.
> >
> >
> > "Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
> >news:b5kvr9$e74$1@news.codecharge.com...
> > > i have found a complete solution
> > > i mean i have made pages to cater a scenario
> > > where one can select multiple values in the list box and after
pressing
> > > submit the database is updated
> > > additionally if i come back to the same record only those values are
> > > selected that were stored in the database
> > > but i had to do the whole thing by hand !
> > > i mean no codecharege studio was involved
> > > i made the whole thing by hand !
> > >
> > > "me" <beach4300@earthlink.net> wrote in message
> > >news:b5ihd9$549$1@news.codecharge.com...
> > > > Hi,
> > > > I am having the same frustration. Are you using PHP? If so what
code
> > did
> > > > you use to get the listbox values into the table? I'm working on
this
> > as
> > > > well and will post my solution if I find one.
> > > > Thanks,
> > > > Walter
> > > > "Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
> > > >news:b5iabc$lm8$1@news.codecharge.com...
> > > > > So far I have found no decent way of storing multiple selected
> values
> > > from
> > > > a
> > > > > multiple selection listbox into the database and then retrieving
> them
> > > > > i dont think this issue has been addressed in codecharge studio
2.0
> as
> > > > well
> > > > > can the developers shed some light on this
> > > > >
> > > > > After a lot of tinkering and with a lot of bad code i was able to
> get
> > > the
> > > > > multiple selection box to store selected values in the database
> > however
> > > no
> > > > > amount of coaxing will let u update it . because when ever one
comes
> > to
> > > > > change the values in the update mode the values (keys) that were
> > > selected
> > > > > previously are unselected
> > > > >
> > > > > Abidoon
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>

Kevin
Posted: 03/30/2003, 5:12 PM

1. Search
If a user enters a search critria then clicks on search you get a list of
different categories, from this list you want to select one to one+n
categories then do what? I use multi-select to move users into different
groups, I do it with a custom before show event, javascript and then a
custom update event.

"DAVID" <codecharge_newsfeed@stridetech.com> wrote in message
news:b62giu$q8j$1@news.codecharge.com...
> Kevin,
> I use multiple select in several applications.
> You questions, comments are prefixed with a '>' sign.
>
> >What function are you trying to do?
> 1. Search.
> User enters keyword(s) in a search box, and selects multiple
categories
> of records he wishes to see.
> example : keyword='hunting' --------> result set 1300 records
> keyword='hunting' , category=['bolt action
> rifle','bolt action pistol'] ---------> result set 103 records
>
> > Select many users and 'goup' them in a group?
> 2. Email list.
> User selects multiple email addresses from address book into To: field
> and chooses to save a draft of the message in the database.
>
> >Pick several items and place them in a container?
> 3. Preferences
> User subscribes to realtime updates for a subset of active channels
> example: channels=['auction posts','auction bids'],
> alertlevel='batched notification', batchtype='time', batchthreshold='600
> sec'
> Application will check the database every 600 seconds
> to see if any records have been updated
> in channels 'auction posts' or 'auction bids' and
> alert the user with a list of updated items.
>
> >Pick several items and place them in a container?
> >Your concept of taking several record objects then placing them into a
> 'textarea'
> >or making them CSV delimited data doesn't make sense to me..
> 4. Access control
> Superuer delegates administration privilege to a user, allowing the
> end user to manage records in groups A-Z.
> example:
>
username='david',allowed_domains=[''stridetech.com','stepback.com'],accessle
> vel='full_access'.
> User david in this example will be able to maintain
> mailboxes(mail users) and aliases(mailing lists) for
> two postfix virtual mail domains, namely
> 'stridetech.com' and 'stepback.com'
>
>
>
>
> "Kevin" <kangus@acats.com> wrote in message
>news:b5vbk0$d48$1@news.codecharge.com...
> > What function are you trying to do? Select many users and 'goup' them in
a
> > group? Pick several items and place them in a container? Your concept of
> > taking several record objects then placing them into a 'textarea' or
> making
> > them CSV delimited data doesn't make sense to me.. using a resolution
> entity
> > seems to be a working solution to your problem.
> >
> >
> > "DAVID" <codecharge_newsfeed@stridetech.com> wrote in message
> >news:b5o02k$47b$1@news.codecharge.com...
> > > I had brought this issue to Yes support in the past.
> > > The following is the reply of a support engineer:
> > >
> > > David,
> > > This behavior is normal by design because in spite of number of items
> > > selected from such listbox only the last value will be added to db.
> > > The data to store in the table is retrieved sequentially from the
> > parameter
> > > string. All the items selected from the listbox are stored in it too,
> but
> > > all of them have the same name, e.g.:
> > > listbox1=item1&listbox1=item3&listbox1=item5
> > >
> > > In case you want to store all the selected values in one (or may be
> > several)
> > > field or implement search it requires custom code. Please refer to the
> > > GotoCode article "Creating multiple-selection listboxes in CCS" at
> > > http://gotocode.com/art.asp?art_id=201&
> > > In addition to it I emailed you sample CCS project that demonstrates
the
> > > multiple selection functionality. It includes PHP events but I hope it
> > would
> > > be helpful anyway. Use sample Intranet DB to test it.
> > >
> > > Regards,
> > > Helen
> > >
> > >
> > >
> > > Later on I had to comeup with a set of JavaScript functions that
> > > 1. Convert a delimited string sourced in the database into a multiple
> > > select.
> > > 2. Upon a modification in select rebuild the delimited string.
> > > and
> > > 3. Upon submit, submit the delimited string back to the database.
> > >
> > >
> > > "Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
> > >news:b5kvr9$e74$1@news.codecharge.com...
> > > > i have found a complete solution
> > > > i mean i have made pages to cater a scenario
> > > > where one can select multiple values in the list box and after
> pressing
> > > > submit the database is updated
> > > > additionally if i come back to the same record only those values are
> > > > selected that were stored in the database
> > > > but i had to do the whole thing by hand !
> > > > i mean no codecharege studio was involved
> > > > i made the whole thing by hand !
> > > >
> > > > "me" <beach4300@earthlink.net> wrote in message
> > > >news:b5ihd9$549$1@news.codecharge.com...
> > > > > Hi,
> > > > > I am having the same frustration. Are you using PHP? If so what
> code
> > > did
> > > > > you use to get the listbox values into the table? I'm working on
> this
> > > as
> > > > > well and will post my solution if I find one.
> > > > > Thanks,
> > > > > Walter
> > > > > "Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
> > > > >news:b5iabc$lm8$1@news.codecharge.com...
> > > > > > So far I have found no decent way of storing multiple selected
> > values
> > > > from
> > > > > a
> > > > > > multiple selection listbox into the database and then retrieving
> > them
> > > > > > i dont think this issue has been addressed in codecharge studio
> 2.0
> > as
> > > > > well
> > > > > > can the developers shed some light on this
> > > > > >
> > > > > > After a lot of tinkering and with a lot of bad code i was able
to
> > get
> > > > the
> > > > > > multiple selection box to store selected values in the database
> > > however
> > > > no
> > > > > > amount of coaxing will let u update it . because when ever one
> comes
> > > to
> > > > > > change the values in the update mode the values (keys) that were
> > > > selected
> > > > > > previously are unselected
> > > > > >
> > > > > > Abidoon
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>

DAVID
Posted: 03/31/2003, 8:14 AM

I do not get what you're saying. I think I thoroughly explained why and how
multiple select is used in MY apps.
a) Sometimes I need to save options selected in multiple into a database
field (eg: save a list of comma delimited email addresses into a "to" field
of an email message draft)
b) Sometimes I need to modify parameters to an sql data source (eg: select
products belonging to specific categories)
What isn't clear? Yes, sometimes you need to use custom events. I do not
disagree. If you recall the original question, it was:

"So far I have found no decent way of storing multiple selected values from
a
multiple selection listbox into the database and then retrieving them
i dont think this issue has been addressed in codecharge studio 2.0 as well
can the developers shed some light on this

After a lot of tinkering and with a lot of bad code i was able to get the
multiple selection box to store selected values in the database however no
amount of coaxing will let u update it . because when ever one comes to
change the values in the update mode the values (keys) that were selected
previously are unselected

Abidoon"












"Kevin" <kangus@acats.com> wrote in message
news:b684lv$6s2$1@news.codecharge.com...
> 1. Search
> If a user enters a search critria then clicks on search you get a list of
> different categories, from this list you want to select one to one+n
> categories then do what? I use multi-select to move users into different
> groups, I do it with a custom before show event, javascript and then a
> custom update event.
>
> "DAVID" <codecharge_newsfeed@stridetech.com> wrote in message
>news:b62giu$q8j$1@news.codecharge.com...
> > Kevin,
> > I use multiple select in several applications.
> > You questions, comments are prefixed with a '>' sign.
> >
> > >What function are you trying to do?
> > 1. Search.
> > User enters keyword(s) in a search box, and selects multiple
> categories
> > of records he wishes to see.
> > example : keyword='hunting' --------> result set 1300 records
> > keyword='hunting' , category=['bolt action
> > rifle','bolt action pistol'] ---------> result set 103 records
> >
> > > Select many users and 'goup' them in a group?
> > 2. Email list.
> > User selects multiple email addresses from address book into To:
field
> > and chooses to save a draft of the message in the database.
> >
> > >Pick several items and place them in a container?
> > 3. Preferences
> > User subscribes to realtime updates for a subset of active
channels
> > example: channels=['auction posts','auction bids'],
> > alertlevel='batched notification', batchtype='time', batchthreshold='600
> > sec'
> > Application will check the database every 600
seconds
> > to see if any records have been updated
> > in channels 'auction posts' or 'auction bids' and
> > alert the user with a list of updated items.
> >
> > >Pick several items and place them in a container?
> > >Your concept of taking several record objects then placing them into a
> > 'textarea'
> > >or making them CSV delimited data doesn't make sense to me..
> > 4. Access control
> > Superuer delegates administration privilege to a user, allowing
the
> > end user to manage records in groups A-Z.
> > example:
> >
>
username='david',allowed_domains=[''stridetech.com','stepback.com'],accessle
> > vel='full_access'.
> > User david in this example will be able to maintain
> > mailboxes(mail users) and aliases(mailing lists) for
> > two postfix virtual mail domains, namely
> > 'stridetech.com' and 'stepback.com'
> >
> >
> >
> >
> > "Kevin" <kangus@acats.com> wrote in message
> >news:b5vbk0$d48$1@news.codecharge.com...
> > > What function are you trying to do? Select many users and 'goup' them
in
> a
> > > group? Pick several items and place them in a container? Your concept
of
> > > taking several record objects then placing them into a 'textarea' or
> > making
> > > them CSV delimited data doesn't make sense to me.. using a resolution
> > entity
> > > seems to be a working solution to your problem.
> > >
> > >
> > > "DAVID" <codecharge_newsfeed@stridetech.com> wrote in message
> > >news:b5o02k$47b$1@news.codecharge.com...
> > > > I had brought this issue to Yes support in the past.
> > > > The following is the reply of a support engineer:
> > > >
> > > > David,
> > > > This behavior is normal by design because in spite of number of
items
> > > > selected from such listbox only the last value will be added to db.
> > > > The data to store in the table is retrieved sequentially from the
> > > parameter
> > > > string. All the items selected from the listbox are stored in it
too,
> > but
> > > > all of them have the same name, e.g.:
> > > > listbox1=item1&listbox1=item3&listbox1=item5
> > > >
> > > > In case you want to store all the selected values in one (or may be
> > > several)
> > > > field or implement search it requires custom code. Please refer to
the
> > > > GotoCode article "Creating multiple-selection listboxes in CCS" at
> > > > http://gotocode.com/art.asp?art_id=201&
> > > > In addition to it I emailed you sample CCS project that demonstrates
> the
> > > > multiple selection functionality. It includes PHP events but I hope
it
> > > would
> > > > be helpful anyway. Use sample Intranet DB to test it.
> > > >
> > > > Regards,
> > > > Helen
> > > >
> > > >
> > > >
> > > > Later on I had to comeup with a set of JavaScript functions that
> > > > 1. Convert a delimited string sourced in the database into a
multiple
> > > > select.
> > > > 2. Upon a modification in select rebuild the delimited string.
> > > > and
> > > > 3. Upon submit, submit the delimited string back to the database.
> > > >
> > > >
> > > > "Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
> > > >news:b5kvr9$e74$1@news.codecharge.com...
> > > > > i have found a complete solution
> > > > > i mean i have made pages to cater a scenario
> > > > > where one can select multiple values in the list box and after
> > pressing
> > > > > submit the database is updated
> > > > > additionally if i come back to the same record only those values
are
> > > > > selected that were stored in the database
> > > > > but i had to do the whole thing by hand !
> > > > > i mean no codecharege studio was involved
> > > > > i made the whole thing by hand !
> > > > >
> > > > > "me" <beach4300@earthlink.net> wrote in message
> > > > >news:b5ihd9$549$1@news.codecharge.com...
> > > > > > Hi,
> > > > > > I am having the same frustration. Are you using PHP? If so
what
> > code
> > > > did
> > > > > > you use to get the listbox values into the table? I'm working
on
> > this
> > > > as
> > > > > > well and will post my solution if I find one.
> > > > > > Thanks,
> > > > > > Walter
> > > > > > "Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
> > > > > >news:b5iabc$lm8$1@news.codecharge.com...
> > > > > > > So far I have found no decent way of storing multiple selected
> > > values
> > > > > from
> > > > > > a
> > > > > > > multiple selection listbox into the database and then
retrieving
> > > them
> > > > > > > i dont think this issue has been addressed in codecharge
studio
> > 2.0
> > > as
> > > > > > well
> > > > > > > can the developers shed some light on this
> > > > > > >
> > > > > > > After a lot of tinkering and with a lot of bad code i was able
> to
> > > get
> > > > > the
> > > > > > > multiple selection box to store selected values in the
database
> > > > however
> > > > > no
> > > > > > > amount of coaxing will let u update it . because when ever one
> > comes
> > > > to
> > > > > > > change the values in the update mode the values (keys) that
were
> > > > > selected
> > > > > > > previously are unselected
> > > > > > >
> > > > > > > Abidoon
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>

Don Anderson
Posted: 04/13/2003, 10:37 PM

Dear Abidoon Nadeem,

Last year I had similar needs for multiple selection listboxes. The
following posting was originally from July 15 2002. It relates to CCS 1.07.
Nevertheless, it does detail what was necessary to make multiple selection
listboxes fully functional.
If you skip down to point 4. below you will see how I made the Listboxes
build dynamically and thus retain existing values.

I was hoping that Yes Software would implement multiselects in version 2,
but apparently that hasn't been the case. :-(

I haven't checked out CCS 2.0 thoroughly, so I'm not sure how many of the
previous issues (like CCS mangling incoming arrays) still remain. The
modifications below will need to be updated for CCS version 2 but I hope
this is a helpful reference or starting point.

Regards,
Don Anderson



"Abidoon Nadeem" <abidoon@mindblazetech.com> wrote in message
news:b5iabc$lm8$1@news.codecharge.com...
> So far I have found no decent way of storing multiple selected values from
a
> multiple selection listbox into the database and then retrieving them
> i dont think this issue has been addressed in codecharge studio 2.0 as
well
> can the developers shed some light on this
>
> After a lot of tinkering and with a lot of bad code i was able to get the
> multiple selection box to store selected values in the database however no
> amount of coaxing will let u update it . because when ever one comes to
> change the values in the update mode the values (keys) that were selected
> previously are unselected
>
> Abidoon

Greetings everyone.

I write to share my experience getting multiple selection listbox updates
working in CCS. I had some guidance from CodeCharge Support for which I'm
thankful, but much of the solution is my own and edits files that Yes
Software probably wouldn't recommend. :-) PROCEED AT YOUR OWN RISK AND
ALWAYS MAKE BACKUP COPIES OF MODIFIED FILES.

My situaton called for the webuser to be able to make multiple selections in
a listbox and have these stored in a lookup table. When the update form is
shown options previously selected need to be taken from the lookup table and
the appear selected in the listbox.

Issues:

1. Listbox variable array.
2. Invalid variable type.
3. Fetching data from the lookup table.
4. Building the Listbox
5. Saving multiple options.


1. Listbox variable type.
=================
Unless you specify the Listbox as an array, eg. <select name="ListBox[]"
multiple size=8> each selected option will write over the previous one.
Accordingly, you have to inclde the square brackets at the end of the
listbox name [] so that all options will be preserved by the form.

Unfortunately, CCS doesn't like this, cannot find the original listbox and
keeps offering to delete it. You must always tell CCS no. For this reason,
I left the array[] specification to the very last step. Actually, I did
this step outside of CCS after the code had been generated. You edit the
html template file.

2. Invalid variable type.
================
The next problems that one encounters is that CCS automatically validates
variables and crunches arrays.

The first change requitred is in Classes.php around line 400. I modified
function/method clsControl in Class clsControl as follows.

###### Beginning of clsControl Function
function clsControl($ControlType, $Name, $Caption, $DataType, $Format,
$InitValue)
{
$this->Value = "";
$this->Text = "";
$this->Page = "";
$this->Parameters = "";
$this->CCSEvents = "";
$this->Values = "";

$this->Required = false;
$this->HTML = false;

$this->Errors = new clsErrors;

$this->Name = $Name;
$this->ControlType = $ControlType;
$this->DataType = $DataType;
$this->Format = $Format;
$this->Caption = $Caption;

// ## Begin Modification
// ## The orginal version lines below kills any $InitValue array (multiple)
that makes it this far
// ## This modification allows through arrays associated with ListBoxes

if (is_array($InitValue) && $this->ControlType == "ccsListBox") {
while (list ($key, $Value) = each ($InitValue)) {
if(strlen($aValue)) {
$this->Text = $aValue;
$this->Value[] = $this->GetParsedValue();
}
}
}elseif(strlen($InitValue)) {
$this->SetText($InitValue);
}

// ## End Modification
}

####### End of clsControl Function


The second issue is that variables are validated according to type before
processing them for a database insert or update. Unfortunately, there is
no "array" type. Accordingly, your Listbox array variable does not pass
validation. I spent time looking through the validation code and attempted
several mods, but finally decided the easiest solution was to comment out
the appropriate line in the "Validate Method" in the php file for the
multiple Listbox/s. See the "Code view" on your page, eg.

// $Validation = ($this->ListBox1->Validate() && $Validation);

This is not a great solution, but it works.

** Beware that once you modify a generated function/method by hand CCS
won't modify that function/method again, so it is advisable to make this
change after you have added everything to your page. **

** Might I suggest that Yes Software introduce an Integer Array variable
type with approriate looped validation. Most multiselect Listboxes should
be able to work with an integer type bound column. This would prevent the
need to manually bypass the validation functions.



3. Fetching data from the lookup table.
===========================
One has to query the appropriate lookup table to get any options selected.
This could be achieved by inserting a before show event or by including the
necessary code in the "Control Source" area of the Listbox Data Properties
tab.

I prefered the later option and decided to modify Common.php by adding the
following function to simplify the "Control Source" code:

//CCGetSelectList
function CCGetSelectList($db, $sql, $bound_column = "")
{
$values = "";
if(!strlen($bound_column))
$bound_column = 0;
$db->query($sql);
if ($db->next_record())
{
do
{
$values[] = $db->f($bound_column);
} while ($db->next_record());
}
return $values;
}

//End CCGetSelectList


USAGE for function CCGetSelectList is as follows:

CCGetSelectList($db, $sql, $bound_column)

where:

$db is the connection name you want to use,
$sql is the sql statement (including where
statement) to use
$bound_column is the name of the column containing the values to use
from the result set.

Here is an example of usage in the "Control Source" area for a ListBox Data
properties: <> values indicate substitutions.

CCGetSelectList($this->ListBox1_ds, "SELECT <bound_column_id> as
<bound_column> from <table_name> WHERE <other_lookup_table_column> = ".
CCGetParam('<lookup_value>',"0"), <bound_column>)




4. Building the Listbox
================
By default CCS inserts a "SELECT VALUE" selected option at the beginning of
every select listbox. This works with a non-multiple listbox because a
selected value overrides the initial default "SELECT VALUE" option. It does
not work for a multiple select ListBox.

I decided to add code to build ListBoxes dynamically. :-) Again we are
modifying Classes.php.
In the original unmodified the Show function/method starts at line 493 and
the "case ccsListBox" code starts at line 553.

Here is what I did to the case ccsListBox code in the Show function/method
of Classes.php. It is not the flashest code but it worked for me. :-)


case ccsListBox:
// BEGIN MOD

$Options = "";

## NOTE Your can change the default no selection message in the next line
## And if you set the value for List_Message earlier it will be used here.

if (!strlen($this->List_Message)) $this->List_Message = "No Selection";

$sel_list = "";
$unsel_list = "";

if (!is_array($this->Value)) $this->Value =
preg_split('/,|(%2C)/',$this->Value);

if(is_array($this->Values))
{
for($i = 0; $i < sizeof($this->Values); $i++)
{
$Value = $this->Values[$i][0];
$Text = $this->Values[$i][1];

if(in_array($Value,$this->Value)) {
$sel_list .= '<option value="' .$Value. '"
selected>' . $Text .'</option>\n';
} else {
$unsel_list .= '<option value="' .$Value. '">' .
$Text .'</option>\n';
}
}
}

if (!strlen($sel_list)) {
$sel_list .= '<option value = "">' .$this->List_Message.
'</option>\n';
}

$Options .= $sel_list .= $unsel_list;
$Tpl->SetVar($this->Name . "_Options", $Options);
break;
}
// END MOD

}

// END OF SHOW FUNCTION

Using this code one should edit the html view of the CCS generated listbox
code to remove the "SELECT VALUE" line for your ListBox control.

Your multiple ListBoxes should now be dynamically generated with all
selected options appearing at the beginning of the selection list.


5. Saving multiple options.
==================

This part is the most manual. It involves writing custom
AfterExecuteDelete, AfterExecuteInsert & AfterExecuteUpdate statements.

A Delete statement is straightforward. An Update statement is a Delete then
an Insert statement using the index value being updated.
Where you just do a custom Insert you have to first retrieve the new index
value that was created when the main CCS form did its insert.

Two things I found useful:

Calling $HTTP_POST_VARS
--------------------------------
I avoided array variables being mangled or rejected the validation code by
calling the selected options directly from $HTTP_POST_VARS,

Remember to insert the line:

global $HTTP_POST_VARS;

then you can fetch the array with code like this example:

$valuelist = $HTTP_POST_VARS[$form_field];


Obtaining the Last_ID value for subsequent INSERT.
-----------------------------------------------------
To get the most recent index value with MySQL I used the following code:

$db = $project->ds;
$thekey = CCGetDBValue("SELECT MAX(project_id) FROM ri_projects", $db);

I know this could fail under very heavy load with simultaneous inserts,
however, this should not be a problem with my application and I couldn't
figure out how to get mysql_insert_id() working.


UPDATE QUERY
--------------------

For the Upate insert I wrote a code that could be called as a function but I
settled on inserting it as necessary.

I set up an array that contained the parameters required for doing updates
for each control, then cycled through each.

global $DBconnection_name;
global $Form_name;

global $HTTP_POST_VARS;


/* $these = array(
array(
$lookup_table, // name of table being updated
$form_field // The form element name
$update_field, // name of field being updated with
distinct values
$thekey_field // the where field, probably similar to
*form* name
)
)
*/
// E.G.
$these = array(
array( ri_partners,
partners,
org_id,
project_id
),
array( ri_funders,
funders,
org_id,
project_id
)
);


$db = <Data_Connection_To_Use_ds>;

for($ix = 0; $ix < sizeof($these); $ix++)
{
list($lookup_table, $form_field, $update_field, $thekey_field) =
$these[$ix];

$thekey = "";
$valuelist = "";
$thekey = CCGetParam($thekey_field,"");
$valuelist = $HTTP_POST_VARS[$form_field];

if (!is_array($valuelist)) $valuelist =
preg_split('/,|(%2C)/',$valuelist);

for($i = 0; $i < sizeof($valuelist); $i++)
{
if ($valuelist[$i]) {
$sql = "";
$sql = "INSERT INTO ". $lookup_table ." ("
. $thekey_field .", "
. $update_field
. ") VALUES ("
. $thekey . ", "
. $valuelist[$i]
. ")";
$db->query($sql);
}
}
}




I trust this report will be helpful to somebody. I realise that it does not
cover the issue of creating a multiple select ListBox for a search form. The
issues are however very similar. You need to collect the variables and then
create a custom BeforeBuildSelect event to modify the WHERE code.

Regards,
Don Anderson





   


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.