katmanrocks
Posts: 8
|
| Posted: 06/19/2006, 2:03 PM |
|
I have an app with a listbox that is used to populate a label. It works fine. When the fourth item is selected on the list, that value moves to the label (using the client side "On Change" event).
I want to add the ability where there is only one value in the listbox returned by the server to "automatically" populate the label. How can I do that? Is there a property that can be accessed to check how many values are in the listbox and if it is "1", update the label? I am using asp. Where would I place that event (after execute select?)?
Thanks
|
 |
 |
marcwolf
Posts: 361
|
| Posted: 06/19/2006, 4:20 PM |
|
Hi There
When mutilple selections are returned from a list box they are passed back as a comma seperated string.
So you can either do a INSTRING to look for a comma, and if there is then you have mutiple items.
If you need to use the items anyway you can use a SPLIT function to put the string insto an array using the comma as your delimiter. And then use the UBOUND to get the number of elements in the array. You can then loop through the array and use the values.
Once you have the number of items then it is a case of just using the following
if XXX = 1 then label.value = "your value here"
Hope this helps
Dave
p.s. The same concepts can be used on the client side with Javascript.
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
followup
|
| Posted: 06/20/2006, 6:39 AM |
|
If I use the client side "On Load", how would I reference the index? I have provided a sample.
//Check the current count of items in the listbox
if (document.NEW_ORDER_FORM.Access_Order_List.options[document.NEW_ORDER_FORM.Access_Order_List.ListCount].value = 1)
{
document.NEW_ORDER_FORM.Access_Order.value=document.NEW_ORDER_FORM.Access_Order_List.options[document.NEW_ORDER_FORM.Access_Order_List.Index.1].value;
}
|
|
|
 |
|