Trouble with retrieving data from a database into a form list box

Results 1 to 2 of 2

Thread: Trouble with retrieving data from a database into a form list box

  1. #1
    Join Date
    Dec 1969
    Posts
    30

    Default Trouble with retrieving data from a database into a form list box

    I use the same form for updation and addition of a new record to a database with some cookies. in my database I have a single value of month(say march). while in the form it is a list of months from january to december. I am using seesions to restore other form field values. how can i retrieve that single month value(March) in to the list box. I think I can do that by passing a cookie and using if. Please throw some light on this. any other suggestions are appreciated.

  2. #2
    Ben Jones Guest

    Default RE: Trouble with retrieving data from a database into a form list box

    I&#039m not sure I really understand the exact example you need, but I think this should do the trick. If you&#039re using sessions you&#039ll have to change it around. I&#039m also not sure if in your setup you&#039ve got the month stored as a number or a string. In this example I&#039ll use both, but do the matching on the string value.<BR><BR>&#060;HTML><BR>&#060;HEAD><BR>&#060; TITLE>Demo Form Select&#060;/TITLE><BR>&#060;/HEAD><BR><BR>&#060;BODY><BR>&#060;FORM><BR><BR>&#0 60;SELECT name="monthVal"><BR>&#060;%<BR><BR>&#039 let&#039s assume we want to auto-select the current month<BR>this_month = month(date)<BR>this_month_name = monthname(month)<BR><BR>for x = 1 to 12<BR> if monthname(x) = this_month_name then<BR> selected_text = " SELECTED"<BR> else<BR> selected_text = ""<BR> end if<BR> &#037;&#062;<BR> &#060;option value="&#060;%= monthname(x) &#037;&#062;"&#060;%= selected_text &#037;&#062;>&#060;%= monthname(x) &#037;&#062;&#060;/option><BR> &#060;%<BR>next<BR><BR>&#037;&#062;&#060;/SELECT>&#060;P><BR><BR>&#060;/FORM><BR><BR>&#060;/BODY><BR>&#060;/HTML><BR><BR>If you&#039re storing by numeric value then the comparison line would instead read:<BR><BR>if x = this_month then

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •