CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Values from Multiselect list box or checkbox list (RESOLVED)

Print topic Send  topic

Author Message
saseow

Posts: 744
Posted: 09/11/2009, 5:04 PM

I do hope this is possible:

I have a text area control in a record form. I want the user to be able to select multiple items from a listbox that will then be inserted into the text area.

Any ideas would be such a help. Thank you!
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/11/2009, 11:21 PM

Hi

There are a couple ways to do this depending on your requirements.

1. If the multiple selects can just be selected and re-displayed as a multi selected listbox.
(In other words just represent the multi selections in the drop down instead of having to
move them into a text area. I mention this because how will you handle record
updates?? Erase the text area the the user would have to re-enter the old ones from
the list box and make changes???)

2. Do you want the text area to be added to before the page is submitted, displaying the
selections as hey are made.

3. Moved the selection into the textarea for saving in the database only.

Let me know which way you want this to work.

I do recomend just keeping it in the dropdown showing multiple selected but you might have another reason to want it in a textarea. Do consider how you want updates to this thing to work.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
damian

Posts: 838
Posted: 09/12/2009, 12:59 AM

there are many javascript examples similar to this on javascript.internet.com
as john suggests you might want seperate insert and update forms....

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
saseow

Posts: 744
Posted: 09/12/2009, 3:22 AM

Thank you John and Damian,

I expect to have the multi listbox available above the textarea. I must show the text area is case the user wants to delete any items as you suggested John.

The best scenario would be your number two John. In this way the user could delete items and add item and see what was going on:

2. Do you want the text area to be added to before the page is submitted, displaying the
selections as they are made. (This would be very nice).

I guess it will have to be done with javascript but I am pretty stuck as to how to read the listbox selected values and then pop them into the text area.

View profile  Send private message
saseow

Posts: 744
Posted: 09/12/2009, 3:22 AM

Thank you John and Damian,

I expect to have the multi listbox available above the textarea. I must show the text area is case the user wants to delete any items as you suggested John.

The best scenario would be your number two John. In this way the user could delete items and add items and see what was going on:

2. Do you want the text area to be added to before the page is submitted, displaying the
selections as they are made. (This would be very nice).

I guess it will have to be done with javascript but I am pretty stuck as to how to read the listbox selected values and then pop them into the text area.

View profile  Send private message
saseow

Posts: 744
Posted: 09/12/2009, 3:29 AM

John, perhaps it would be easier to keep only the listbox on the form then do the code before. I am a bit confused as to how I will redisplay the multiselect listbox in a non editable record form or a report if this is what you are talking about 'If the multiple selects can just be selected and re-displayed as a multi selected listbox.'

Can you please clarify this.
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/12/2009, 6:07 AM

Hi

That's what I meant, It would be easier and cleaner on input and edit pages to keep it a multiple listbox, allowing for input and update of the records.

When the listbox displays, all selected options would be highlighted and to select multiples, all you do is hold the cotrol key down.

Since these values will now be arrays, all you need to do is use a comma/space pair to be the array delimiter. By doing that, the multiple values will display as

item1, item2, item3

on non-editable pages and reports.

If you need help wil the code to do this, let me know

John


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
damian

Posts: 838
Posted: 09/12/2009, 6:16 AM

try this: http://javascript.internet.com/forms/pass-multiple-values.html
if you changed code from onSubmit to onClick or onSelect it should add straight away
to use multiple select add this multiple="multiple" inside the select tag
dont know how you would handle someone unselecting an item

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
saseow

Posts: 744
Posted: 09/12/2009, 6:21 AM

John, I do need some help with the code.

If you have a minute it would be great if you could help out. I have had a look at Damian's example but my javascript is so bad I can't make sense of it.
View profile  Send private message
saseow

Posts: 744
Posted: 09/12/2009, 6:32 AM

Hold on John, I may have got a very easy way around this.

I have put a standard listbox just above the textarea and in the OnChange event of the list box I am getting the value and passing it to the textarea:
<code>
num=document.si_resources.ListBox1.value;
tot=tot+", "+num;
document.si_resources.availability.value = tot;
</code>

Is this OK and is there a better way?
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/12/2009, 7:27 AM

Hi

I just posted the working multi-item list box at CCSE.

http://ccselite.com/forums_topics_view.php?forum_id=2&forum_topic_id=101

There are always many ways to skin a cat in software.

Personally I would use the multi item listbox.

But that is certainly a design decision you need to make.

I think filling a text box with values from a drop down using onchange to populate the text area would be messy during maintenance of your database, particularly if the only reason yu are doing it is for non editable pages and reports.

I could be wrong.

Let me know what you finally do


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/12/2009, 7:28 AM

BTW it is only 6 lines of PHP Code.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
saseow

Posts: 744
Posted: 09/12/2009, 7:50 AM

Thanks so much John. I am going to give it a try now and will let you know.

Best regards,

Trevor
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/12/2009, 7:56 AM

LOL

If you want to get exotic about it you could use

http://realtest.biz/DND/

;-)
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/12/2009, 7:58 AM

Cool

Hope it helps.

Let me know

John

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
saseow

Posts: 744
Posted: 09/12/2009, 8:25 AM

John, that is incredible! Works as advertised! Well Done!

Thank you so much for your time and effort!

With kindest regards,

Trevor
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.