Thread: how to make default for dynamic list

  1. #1
    Microsoft Lover afreedboy's Avatar
    Join Date
    Nov 2003
    Posts
    189

    how to make default for dynamic list

    Currently i am trying a simple database. I got birthday from users and store in database. When i want to update i will show the page with drop down menu. But if user have entered it december, i want default of the list to be december.
    here is what I tried
    Code:
      <select name=brith_Month id="brith_Month">
    			  	<OPTION SELECTED="selected"><%=rs("brith_Month")%>
                        <option value=JANUARY>JANUARY 
                        <option value=FEBRUARY>FEBRUARY 
                        <option 
            value="MARCH ">MARCH 
                        <option value=APRIL>APRIL 
                        <option 
            value=MAY>MAY 
                        <option value="JUNE ">JUNE 
                        <option value="JULY ">JULY 
                        <option 
            value=AUGUST>AUGUST 
                        <option value="SEPTEMBER ">SEPTEMBER 
                        <option 
            value=OCTOBER>OCTOBER 
                        <option value=NOVEMBER>NOVEMBER 
                        <option 
            value=DECEMBER>DECEMBER</option>
                  </select>
    what that would be two december.

    is there anyone know how to do it for just one value.

  2. #2
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    First off, you need to close each option with a </option> tag.

    Secondly, you need to have a value in the "selected" option.

    Thirdly, it's "birth_month", unless you meant to spell it that way.

    Fourthly, what you should be doing is using a loop to remove the option that is selected so that you don't have 2.

  3. #3
    Microsoft Lover afreedboy's Avatar
    Join Date
    Nov 2003
    Posts
    189
    Can u show me how to make a loop?

  4. #4
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    What language? PHP? ASP? Perl? JS?

  5. #5
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    Here's the PHP version, but it assumes you're storing your birth month as an integer. I assume you're using ASP, so you may have to change it. I don't know ASP, so I can't help you there. Search Google... it may give you the answer.

    Code:
    <select name="blah">
    <?php
    for($i=1;$i<13;$i++)
    {
    	if($i != $row['birth_month'])
    		echo "<option value=\"$i\">" . date ("F", mktime (0,0,0,$i,1,2005)) . "</option>";
    }
    ?>
    </select>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. urgent help please...
    By peter_hii in forum C++ Programming
    Replies: 11
    Last Post: 10-30-2006, 06:37 AM
  2. urgent please please..
    By peter_hii in forum C++ Programming
    Replies: 4
    Last Post: 10-30-2006, 06:35 AM
  3. Replies: 6
    Last Post: 03-02-2005, 02:45 AM
  4. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM