pass the javascript variable to php page

Thread Solved

Join Date: Nov 2007
Posts: 107
Reputation: kings has a little shameless behaviour in the past 
Solved Threads: 2
kings's Avatar
kings kings is offline Offline
Junior Poster

pass the javascript variable to php page

 
0
  #1
Mar 12th, 2008
Is it possible to pass the javascript varible from one php page to another php page. what is the syntax we use.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 561
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: pass the javascript variable to php page

 
0
  #2
Mar 12th, 2008
you can pass the javascript variables to another page:

  1. <script type="text/javascript">
  2. var x="one";
  3. window.location.href = "yourpage.php?var=" + x;
  4. </script>

yourpage.php
  1. $var=$_GET['var'];
  2. echo $var;
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 107
Reputation: kings has a little shameless behaviour in the past 
Solved Threads: 2
kings's Avatar
kings kings is offline Offline
Junior Poster

Re: pass the javascript variable to php page

 
0
  #3
Mar 19th, 2008
thanks for the above code how to pass more than one variable to the same page using the single link
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 561
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: pass the javascript variable to php page

 
0
  #4
Mar 19th, 2008
just add it to the link like this:

  1. <script type="text/javascript">
  2. var x="one";
  3. var y="one";
  4. window.location.href = "yourpage.php?var=" + x + "&var2=" + y;
  5.  
  6. </script>

then:

  1. $var=$_GET['var'];
  2. $var2=$_GET['var2'];
  3.  
  4. echo $var."<br>";
  5. echo $var2;
Last edited by ryan_vietnow; Mar 19th, 2008 at 2:49 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 107
Reputation: kings has a little shameless behaviour in the past 
Solved Threads: 2
kings's Avatar
kings kings is offline Offline
Junior Poster

Re: pass the javascript variable to php page

 
0
  #5
Mar 19th, 2008
thank a lot for ur help
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC