passing a variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gubbachchi
    New Member
    • Jan 2008
    • 59

    passing a variable

    Hi,

    How to get the value passed using javascript in the next page. The code I have used is this.

    cal.php

    Code:
    <html>
    <head>
    
    </head>
    <script type="text/javascript">
    function Show(){     
    
    	
    	var date_id = document.getElementById("date_id").value;
    
     //alert(date_id);
    self.location='display.php?'+date_id; 
    }
    <body>
    <script type="text/javascript" src="date-picker.js"></script>
    <form name="Calender1" action="display.php" method="POST">
    <a STYLE="text-decoration: none" onmouseover="window.status='Date Picker';return true;" onmouseout="window.status='';return true;" href="javascript:show_calendar('Calender1.date_id')" >
    
    <IMG title="calendar" height=21 src="iconCalendar.gif" width=30 border=0></a>&nbsp;&nbsp;
    <input type="textbox" class="textBox" type="text" readonly name="date_id" id="date_id" size="10">
    </form>
    <input type="submit" value="UPDATE" onclick="Show()">	
    </body>
    </html>
    And I am trying to receive the value of date_id variable in the display.php page like this

    display.php

    Code:
    <?php
    
    	$id = $_GET['date_id'];
    	print $id;
    ?>
    But I am not able to get the date variable in the display.php page. Does anybody have an idea as how to do this.

    With regards
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    You are just passing the variable value, but not variable name.[code=javascript]self.location=' display.php?dat e_id'+date_id;[/code]
    Do this change in line 12.

    Comment

    • gubbachchi
      New Member
      • Jan 2008
      • 59

      #3
      Hi,

      Thanks for the solution.
      It is working

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        [code=javascript]self.location=' display.php?dat e_id='+date_id;[/code]I missed the '=' though.

        Comment

        Working...