Page 1 of 1

Submit button & functions?

Posted: Mon May 16, 2005 6:22 pm
by Ir0nSpIkE
I've created a functions that creates a Month dropdown that is pre-populated with the current month + x. Something like:

Code: Select all

function MonthDropDown($size=90,$default="DropDate") 
{  $skip=1;
   echo "<select name=$default STYLE=\"font-family: monospace;\">\n";
   for ($i = 0; $i <= $size; $i++) 
   {  $theMonth = mktime (0,0,0,date("m") ,date("d")+$i ,date("Y"));
      $option=date("D M j, Y",$theday);
      ...  
   }
   echo "</select>\n";
   return  date("m/d/Y",$theMonth);
}
At the moment I have 3 functions for month day & year. I concatinate the results into the date format I want. My problem is how to use this date as input to a submit button to another page. Or am I going up a tree using this approach?

Jcart | Please use

Code: Select all

tags when posting php code.  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Mon May 16, 2005 7:19 pm
by SBro
Put the date into a session and then retrieve it on the next page ie.

Code: Select all

session_start();

function MonthDropDown($size=90,$default="DropDate") 
{  $skip=1;
   echo "<select name=$default STYLE=\"font-family: monospace;\">\n";
   for ($i = 0; $i <= $size; $i++) 
   {  $theMonth = mktime (0,0,0,date("m") ,date("d")+$i ,date("Y"));
      $option=date("D M j, Y",$theday);
      ...  
   }
   echo "</select>\n";
   return  date("m/d/Y",$theMonth);
}

$_SESSION['date'] = MonthDropDown();
Then on the next page where you want to put it into a input field:

Code: Select all

&lt;?php session_start(); ?&gt;
&lt;input type=&quote;Submit&quote; name=&quote;Date&quote; value=&quote;&lt;?=$_SESSION&#1111;'date'];?&gt;&quote;&gt;

Posted: Tue May 17, 2005 12:07 am
by Burrito
or you could use JS and do it all on one page...