By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,738 Members | 1,730 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,738 IT Pros & Developers. It's quick & easy.

passing a variable

P: 59
Hi,

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

cal.php

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  
  4. </head>
  5. <script type="text/javascript">
  6. function Show(){     
  7.  
  8.  
  9.     var date_id = document.getElementById("date_id").value;
  10.  
  11.  //alert(date_id);
  12. self.location='display.php?'+date_id; 
  13. }
  14. <body>
  15. <script type="text/javascript" src="date-picker.js"></script>
  16. <form name="Calender1" action="display.php" method="POST">
  17. <a STYLE="text-decoration: none" onmouseover="window.status='Date Picker';return true;" onmouseout="window.status='';return true;" href="javascript:show_calendar('Calender1.date_id')" >
  18.  
  19. <IMG title="calendar" height=21 src="iconCalendar.gif" width=30 border=0></a>&nbsp;&nbsp;
  20. <input type="textbox" class="textBox" type="text" readonly name="date_id" id="date_id" size="10">
  21. </form>
  22. <input type="submit" value="UPDATE" onclick="Show()">    
  23. </body>
  24. </html>
And I am trying to receive the value of date_id variable in the display.php page like this

display.php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.     $id = $_GET['date_id'];
  4.     print $id;
  5. ?>
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
Mar 4 '08 #1
Share this Question
Share on Google+
3 Replies


hsriat
Expert 100+
P: 1,654
You are just passing the variable value, but not variable name.
Expand|Select|Wrap|Line Numbers
  1. self.location='display.php?date_id'+date_id;
Do this change in line 12.
Mar 4 '08 #2

P: 59
Hi,

Thanks for the solution.
It is working
Mar 6 '08 #3

hsriat
Expert 100+
P: 1,654
Expand|Select|Wrap|Line Numbers
  1. self.location='display.php?date_id='+date_id;
I missed the '=' though.
Mar 6 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.