Charalabos Michael
|
| Posted: 08/12/2008, 3:32 PM |
|
Hello,
Any ideas how to get the Selected Text value of a Listbox ?
(In custom code of Server side)
Tried $Record1->lbox->Text but it returned the Bound Column value.
(I want the selected text column)
Thank you
|
|
|
 |
datadoit
|
| Posted: 08/12/2008, 5:21 PM |
|
Just do a lookup with the bound column value.
|
|
|
 |
Charalabos Michael
|
| Posted: 08/12/2008, 5:31 PM |
|
Hello datadoit,
> Just do a lookup with the bound column value.
I have 3 listboxes which they're dependent so it will work for first
which it have different "ID" for every value but it will not work
for the other 2 listboxes which they have the same "ID" on every
option .... ?
Thank you
|
|
|
 |
wkempees
Posts: 1679
|
| Posted: 08/12/2008, 6:17 PM |
|
CCDLookup('AA','BB', 'CC=' . DD->ToSQL($Record1->lbox->GetValue(), ccsInteger), DD )
Where
AA is the name of the textfield within the SQL table
BB is the name of the table
CC is the name of the field to test in the WHERE
DD is the name of your database connection
which is what Datadoit mean by
Quote :
Just do a lookup with the bound column value.
or juse the DependentListboxes as available in CCS 4+ (Ajax)
or the CodeChargeTools (CCT) listboxes
Just for my own pleasure (and because I spend some time on it)
The clientside version of the original question
var listBox = document.getElementById("category_id");
for(i=0; i<listBox.length; i++)
{
if( listBox.options.selected )
{
document.events.image_url.value = listBox.options.text;
}
}
where "category_id" is the name of the listbox
and "document.events.image_url" is a field on the record form that we want to assign the
text value of the selected item in the listbox to.
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 08/12/2008, 6:19 PM |
|
PS
the above client side code (JS) is placed in the listbox's OnChange event.
Walter
(PS was posted separate and not edited in previous post, because both poster use newsreader and not online forum)
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 08/12/2008, 6:21 PM |
|
Typo:
CCDLookup('AA','BB', 'CC=' . DD->ToSQL($Record1->lbox->GetValue(), ), DD )
should be
CCDLookup('AA','BB', 'CC=' . DD->ToSQL($Record1->lbox->GetValue(), ccsInteger), $DD )
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
Charalabos Michael
|
| Posted: 08/12/2008, 7:25 PM |
|
Hello Walter,
> CCDLookup('AA','BB', 'CC=' . DD->ToSQL($Record1->lbox->GetValue()), DD )
> Where
> AA is the name of the textfield within the SQL table
> BB is the name of the table
> CC is the name of the field to test in the WHERE
> DD is the name of your database connection
>
> which is what Datadoit mean by
> Quote :
> Just do a lookup with the bound column value.
>
The lookup didn't work because as i said the child IDs are the same.
Here's the table:
Table1:
ID - Name
100 - Name100
200 - Name200
300 - Name300
Table2:
ID - Name
100 - Name1000
100 - Name2000
100 - Name3000
200 - Name1000
200 - Name2000
200 - Name3000
300 - Name1000
300 - Name2000
300 - Name3000
Table3:
ID - Name
100 - Name10000
100 - Name20000
200 - Name10000
200 - Name20000
300 - Name10000
300 - Name20000
The $Record1->lbox->GetValue() returns the ID and as you can see the
"child" IDs are the same so it will always lookup the same Text.
> or juse the DependentListboxes as available in CCS 4+ (Ajax)
> or the CodeChargeTools (CCT) listboxes
I used CCT listboxes.
>
> var listBox = document.getElementById("category_id");
> for(i=0; i<listBox.length; i++)
> {
> if( listBox.options.selected )
> {
> document.events.image_url.value =
> listBox.options.text;
> }
> }
>
The problem is that i want a server side solution because i use
the "Mail" function to mail me the current text data of the Record/Form.
or it can be done with another way ?
Thank you very much
|
|
|
 |
wkempees
Posts: 1679
|
| Posted: 08/13/2008, 3:52 AM |
|
Sorry.
your original question is answered both sever and client side.
You should rethink the disgn and content of your tabl2 and table3.
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
datadoit
|
| Posted: 08/13/2008, 6:26 AM |
|
Well can you not do three lookups into the three tables for the three
listbox text values?
As I understand it, you've got three dependent listboxes. After the
listbox values are chosen, you're submitting to the server for which you
want to send an email message. Prior to sending your message, lookup
the three listbox control's text values from their respective tables.
Doesn't matter that the tables share similar ID's as far as I can tell.
You're getting their text values from different tables.
|
|
|
 |
Charalabos Michael
|
| Posted: 08/13/2008, 4:59 PM |
|
datadoit wrote:
> Well can you not do three lookups into the three tables for the three
> listbox text values?
>
> As I understand it, you've got three dependent listboxes. After the
> listbox values are chosen, you're submitting to the server for which you
> want to send an email message. Prior to sending your message, lookup
> the three listbox control's text values from their respective tables.
>
> Doesn't matter that the tables share similar ID's as far as I can tell.
> You're getting their text values from different tables.
It does ... the table's IDs where wrong :)
Thank you
|
|
|
 |
Charalabos Michael
|
| Posted: 08/13/2008, 5:01 PM |
|
Hello Walter,
> Sorry.
> your original question is answered both sever and client side.
>
> You should rethink the disgn and content of your tabl2 and table3.
Yes you're right! I redesigned the tables structure correct this time
and it works!
Thank you very much!
|
|
|
 |
wkempees
Posts: 1679
|
| Posted: 08/13/2008, 5:11 PM |
|
You are welcome.
Your original table data would have given you other problems that you might not yet have noticed.
Table2 and table3 had duplicate id's, listboxes don't really like that.
Have you restructured by adding a unique id and using the original as the filter?
just curious.
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
Charalabos Michael
|
| Posted: 08/13/2008, 6:50 PM |
|
Hello Walter,
> You are welcome.
> Your original table data would have given you other problems that you might not
> yet have noticed.
> Table2 and table3 had duplicate id's, listboxes don't really like that.
Indeed that was the problem.
> Have you restructured by adding a unique id and using the original as the
> filter?
Previous structure and bound was:
Table1 has Unique ID
Table2 has MasterID which the detail records matches the Table1 ID
Table3 has MasterID which the detail records matches the Table2 MasterID
Which it was wrong!
Here's the current structure and bounds:
Table1 has Unique ID
Table2 has Unique ID and MasterID which the detail records matches the
Table1 ID
Table3 has Unique ID and MasterID which the detail records matches the
Table2 ID
Table 1 ID <-> Table 2 MasterID
Table 2 ID <-> Table 3 MasterID
CCT Dependent Listboxes Builder made the bounded the listboxes easily.
Then i used the CCDLookup to get the Text from the Unique IDs which the
record returns in After Insert Event as you described.
and everything worked as i wanted! Thank you!!! :)
|
|
|
 |
Charalabos Michael
|
| Posted: 08/13/2008, 6:50 PM |
|
Hello Walter,
> You are welcome.
> Your original table data would have given you other problems that you
might not
> yet have noticed.
> Table2 and table3 had duplicate id's, listboxes don't really like that.
Indeed that was the problem.
> Have you restructured by adding a unique id and using the original as the
> filter?
Previous structure and bound was:
Table1 has Unique ID
Table2 has MasterID which the detail records matches the Table1 ID
Table3 has MasterID which the detail records matches the Table2 MasterID
Which it was wrong!
Here's the current structure and bounds:
Table1 has Unique ID
Table2 has Unique ID and MasterID which the detail records matches the
Table1 ID
Table3 has Unique ID and MasterID which the detail records matches the
Table2 ID
Table 1 ID <-> Table 2 MasterID
Table 2 ID <-> Table 3 MasterID
CCT Dependent Listboxes Builder made the bounded the listboxes easily.
Then i used the CCDLookup to get the Text from the Unique IDs which the
record returns in After Insert Event as you described.
and everything worked as i wanted! Thank you!!! :)
|
|
|
 |
wkempees
Posts: 1679
|
| Posted: 08/13/2008, 7:26 PM |
|
[Solved]
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
|