Author Topic: Setting form variable outside form  (Read 455 times)

0 Members and 1 Guest are viewing this topic.

Offline sazzieTopic starter

  • Enthusiast
  • Posts: 65
    • View Profile
Setting form variable outside form
« on: January 30, 2007, 03:44:26 AM »
Hi guys,

I have a form defined below:

Code: [Select]
<form method="post" action=" <?php echo $_SERVER["PHP_SELF"];?> ">
<select name="month" >
<?php
$months 
= Array("January""February""March""April""May", "June",
 "July""August""September""October""November""December");
for( 
$x 1$x <= count($months); $x++ )
{
       echo 
"<option value=\"$x\"";
       if( 
$x == $month )
       {
echo "selected";
$m $month;
        }
        echo 
">".$months[$x-1]."</option>";
}
?>

</select>
</form>

All I want to do is to be able to use a seperate hyperlinked image on my webpage to scroll through the months in my array. So in addition to being able to select any month in my dropdown list, I want an arrow to scroll through one month per click. ???
I figure that means begin able to set the value of month, possibly as a post variable(don't know if its even possible), outside of the form and refreshing the page.

I have never done anything like this before. Can anyone offer and insight into this?

Thanks  ;)

Offline Fallen_angel

  • Enthusiast
  • Posts: 89
    • View Profile
Re: Setting form variable outside form
« Reply #1 on: January 30, 2007, 03:50:45 AM »
you could use get instead of post

then at the top of the page have  something like

Code: [Select]
$id = $_GET['id'];
then the variable is set in the url , for example for january you could have

www.yoursite.com/page.php?id=january

hope that helps

Offline sazzieTopic starter

  • Enthusiast
  • Posts: 65
    • View Profile
Re: Setting form variable outside form
« Reply #2 on: January 30, 2007, 06:46:41 AM »
I am sure i'm missing something but I don't see how using get instead of post will help influence the value of my drop down list.

I need a way to change the value of month without using the list. This is so I can scroll through my months as well as select from the list.