afrausto
Posts: 66
|
Posted: 03/18/2004, 1:35 PM |
|
Hello All!
Does anyone know of a way to show a default value for a drop-down box when a page is first displayed. For example, I have a page that has a search and grid form. When someone first hits the page I have records for year 2004 appear only. I would like to have the search option for YEAR to display 2004 by default (or better yet the current year). Anyone have any suggestions.
I'm using CCS-ASP-Access.
Thanks.
|
|
|
eallen
Posts: 25
|
Posted: 03/18/2004, 2:02 PM |
|
I don't know if this is the correct way to do it but this is what I have done on a form.
On the form's beforeshow I have put code to assign the control the value. ie: [formname].[controlname].value = "whatever"
If it is some value out of a db table, I do a CCDLookup for the value to fill the control.
Hope that helps because I don't know if that is the correct way or even the best way... it is just the way I did it and it worked... :P
|
|
|
peterr
Posts: 5971
|
Posted: 03/19/2004, 1:34 AM |
|
Hi,
It should be sufficient to enter the default value in the "Default Value" property of the listbox. Although in case of listboxes this would be actually the ID of the record that you'd like to show as default.
BTW, what are you using as the source of "Years"? A database table or List of Values?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
Navneet Kakkar
|
Posted: 03/19/2004, 8:48 AM |
|
I am also facing the same problem, peter could you suggest what should be
done i case the value i want ot be displayed is from the text column, and
the bound to is the id, which is stored in a database table.
--
Thanks
luv
Navneet
aquananu@yahoo.com
9811153443
"peterr" <peterr@forum.codecharge> wrote in message
news:6405abe8c3bbde@news.codecharge.com...
> Hi,
> It should be sufficient to enter the default value in the "Default Value"
property of the listbox. Although in case of listboxes this would be
actually the ID of the record that you'd like to show as default.
> BTW, what are you using as the source of "Years"? A database table or List
of Values?
> _________________
> Peter R.
> YesSoftware Support Representative
> http://support.codecharge.com
> Warning: I use Google
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.631 / Virus Database: 404 - Release Date: 3/17/2004
|
|
|
afrausto
Posts: 66
|
Posted: 03/22/2004, 10:19 AM |
|
Peter,
I'm using a list of values. I would like the current year to be the default value. What would be the best way to accomplish that?
Thanks,
Albert
|
|
|
peterr
Posts: 5971
|
Posted: 03/23/2004, 2:19 AM |
|
You can use some function that calculates/returns the current year. Put the function name in the Default Value property.
The standard ASP function for this would be probably:
Year(Now)
Alternatively, you should be able to assign the default value in the Before Show event. For example:
List1.Value = Year(Now)
Since you're using the list of values then your function would need to return the key/bound value rather than the displayed/text value, if they are different.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
afrausto
Posts: 66
|
Posted: 03/23/2004, 11:04 AM |
|
Peterr,
I have a Listbox called s_Application_Year which is located in a Search form called ApplicationsSearch. Using your example I inserted the following in the Before Event,
ApplicationsSearch.s_Application_Year.Value = Year(Now())
to Dynamically Set the Default Value of a ListBox and when I preview the page it does not do that. Can you tell me what I'm doing wrong.
Thanks.
|
|
|
peterr
Posts: 5971
|
Posted: 03/24/2004, 5:09 PM |
|
You need to set the value to one of the values returned by the listbox, not to the value displayed by the listbox. I only provided an example.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
devinder
|
Posted: 03/24/2004, 9:34 PM |
|
how to add value to a listbox at runtime using asp/javascript
|
|
|
peterr
Posts: 5971
|
Posted: 03/24/2004, 10:51 PM |
|
Regarding ASP, refer to the user manual: http://docs.codecharge.com/studio/html/ProgrammingTechn...stOfValues.html
I don't know about JavaScript though, you can try Google to find such information.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
Fred
|
Posted: 03/26/2004, 5:17 AM |
|
Thanks and sorry to waste you time. I did actually search for the answer in the documentation and did not find this reference.
regards,
Fred
|
|
|
MacK
|
Posted: 04/20/2004, 10:54 AM |
|
I just got mine working using the following:
Listbox.selectedIndex = #
Be sure to replace # with the number of in the index you want. Hope that works!
MacK
|
|
|
MacK
|
Posted: 04/20/2004, 10:56 AM |
|
Also, to add an item to a listbox use the following:
Listbox.addItem (strtext,value,nIndex)
|
|
|