TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 09-13-2009, 02:16 AM   #1 (permalink)
The Acquainted
 
Dave's Avatar
 
Join Date: Apr 2008
Posts: 110
Thanks: 97
Dave is on a distinguished road
Default PHP-html select form not working as hoped...?

Good evening, everyone --

The following code is supposed to generate an html select form with a dropdown list of months, with the CURRENT MONTH pre-selected.

The dropdown list works, but the current month is not pre-selected as the default.

I've spent a lot of time on this, but have been unsuccessful. Thanks for taking a look!

-- Dave

PHP Code:
$arr_month = array(  =>  "January" 
                   
=>  "February"
                   
=>  "March"
                   
=>  "April"
                   
=>  "May"
                   
=>  "June"
                   
=>  "July"
                   
=>  "August"
                   
=>  "September"
                   
10 => "October"
                   
11 => "November"
                   
12 => "December"
                  
) ;

$today date"M-d-y"time() ) ;
echo 
"<div style = 'text-align: center'>\n" ;
echo 
"<h3>Today is $today</h3><hr>\n" ;

// create form containing date selection list 

echo "<form action = 'processform.php'
            method = 'POST'>\n" 
;

$todaymo date"n"time() ) ;

echo 
$todaymo "<br />" ;

echo 
"<label for 'datemo'></label>
      <select name = 'datemo' id = 'datemo'> \n" 

      
for ( 
$n $n <= 12 $n++ )
{
    echo 
"<option value = $n;
    if ( 
$todaymo == $n )
    {
        echo 
" selected" ;
    }
    echo 
"> $arr_month[$n] \n" ;
}
echo 
"</select>" 
Dave is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Validation Not Working :( Guezala Absolute Beginners 27 05-13-2009 08:28 PM
PHP fill in form help sacred_tinker Absolute Beginners 6 10-08-2008 12:28 PM
email fill in form help? PHP sacred_tinker Absolute Beginners 19 05-28-2008 05:58 AM
working with Iframes in php JMHein Absolute Beginners 3 05-17-2008 03:40 PM
Starting with php in my html page Shinoken Absolute Beginners 5 01-08-2008 02:34 PM


All times are GMT. The time now is 11:46 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design