A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: php/javascript confusion...guessing this is easy??

  1. #1
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930

    php/javascript confusion...guessing this is easy??

    Alright, I'm fairly new to php and am not sure of the best way to do this. I've tried it by making a function, posting from the form and nothing seems to be working. I'm sure it's something basic I'm missing...I think I'm mixing my javascript and php and am confused about what I need to do here...

    Anyway, I've got a calendar, which is working great so far. I'm just trying to make a simple set of buttons to increment/decrement the year variable and re-submit the form.

    The year is initially set from a session variable, which is working fine. I'm thinking I should create another variable, unique to this page, that just tracks the amount that the year has been changed. I had started by setting a session variable "DeltaYear" but am not sure I should be changing the session variable on this page...doesn't seem like the right setup.

    Here's the code so far, just looking for something that works for the next/previous button:


    PHP Code:
    <?php session_start();?>
    <script>
       //I had started trying to create functions to set the variable, but couldn't figure out how to call them...
       function prevYear()
       {
          if($delta_year>0)
          {
          $delta_year-1;
          }
       }
       function nextYear()
       {
          $delta_year+1;
       }

    </script>
    </div>
       <div id="content">
       <div id="text" style="width:800px;">      
          <a name="calendar"></a>
          <h2>Calendar</h2>      
                <!--start calendar insert here-->
                <div align = "center">
                <form action="index3.php" method="post">            
                   <input name="Year" type="hidden" id="Year" value="2012" />
                   <!--I tried this with both buttons and href links, but neither worked -->
                   <input name="NextYear" type="button" id="NextYear" value="Next Year" ONCLICK="nextYear" />               
                   <a href='#' onclick='prevYear();'>Next Year</a><br/>            
                </form>           
                <?php
                   
    print "<h2>".$_SESSION["Year"]."</h2><br/>";
                   include(
    "includes/calendar.php");               
                   
    $cal = new calendar();
                   if (!isset(
    $year)){
                      
    $year $_SESSION["Year"];
                      
    $delta_year $_SESSION["DeltaYear"];
                      
    $x=$cal->ShowCalendar($year+$delta_year);                  
                   }
                
    ?>            
                </div>
                <!--end calendar insert here-->
             
       </div>
       </div>
    </div>

    Thanks!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  2. #2
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    Got it! Found the answer here:
    http://www.sitepoint.com/forums/show...n-button-click

    Thanks!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center