Web Analytics Made Easy -
StatCounter Default dates - CodingForum

Announcement

Collapse
No announcement yet.

Default dates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Default dates

    I have a date in my form code and want to set the default dates in the drop down boxes to todays date ... I currently have the following form code.

    What do I need to add to position each drop down box to todays date?

    Many thanks in advance... I am sure this is simple to experts out there - but I don't know how to do this.... Regards, Val

    <tr><td class="tdadminb"><?=$this -> text['date_prob']?></td><td td colspan="2" class="tdadminb">

    <?
    $day = date("j");
    $month = date("m");
    $year = date("Y");
    ?>

    <select name="day">
    <?
    for($i = 1; $i <= 31; $i ++)
    {
    echo("<option>$i</option>");
    }
    ?>
    </select>

    <select name="month">
    <option value="1"><?=$this -> text['jan']?></option>
    <option value="2"><?=$this -> text['feb']?></option>
    <option value="3"><?=$this -> text['mar']?></option>
    <option value="4"><?=$this -> text['apr']?></option>
    <option value="5"><?=$this -> text['may']?></option>
    <option value="6"><?=$this -> text['jun']?></option>
    <option value="7"><?=$this -> text['jul']?></option>
    <option value="8"><?=$this -> text['aug']?></option>
    <option value="9"><?=$this -> text['sep']?></option>
    <option value="10"><?=$this -> text['oct']?></option>
    <option value="11"><?=$this -> text['nov']?></option>
    <option value="12"><?=$this -> text['dec']?></option>
    </select>

    <select name="year">
    <option>2003</option>
    <option>2004</option>
    <option>2005</option>
    <option>2006</option>
    <option>2007</option>
    </select>
    </td></tr>

  • #2
    e.g.

    PHP Code:
    <?
    for($i 1$i <= 31$i ++)
    {
    $SEL = ( $i == $day ) ? 'SELECTED' '' ;
    echo(
    "<option $SEL value=\"$i\">$i</option>");
    }
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

    Comment

    Working...
    X