Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 2163 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

How can I pass a variable from Javascript to PHP?

Thread title: How can I pass a variable from Javascript to PHP?
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
08-20-2008, 11:57 AM
#1
shilpamg is offline shilpamg
Status: Member
Join date: Aug 2008
Location:
Expertise:
Software:
 
Posts: 101
iTrader: 0 / 0%
 

shilpamg is on a distinguished road

  Old  How can I pass a variable from Javascript to PHP?

Please explain me that how can i pass a variable from javascript to PHP?

08-20-2008, 12:03 PM
#2
creativejen is offline creativejen
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
 
Posts: 2,353
iTrader: 25 / 96%
 

creativejen is an unknown quantity at this point

Send a message via MSN to creativejen

  Old

The only way you can do it is by a page load. So basically, your javascript will need to locate the person to say, page.php?var1=result

Then in php, you can get the value of var1 using a simple, echo $_GET['var1'];

And also for future reference, try google.

08-21-2008, 06:28 AM
#3
shilpamg is offline shilpamg
Status: Member
Join date: Aug 2008
Location:
Expertise:
Software:
 
Posts: 101
iTrader: 0 / 0%
 

shilpamg is on a distinguished road

  Old

Originally Posted by enigma View Post
The only way you can do it is by a page load. So basically, your javascript will need to locate the person to say, page.php?var1=result

Then in php, you can get the value of var1 using a simple, echo $_GET['var1'];

And also for future reference, try google.
Any other way to pass variable. I mean to say through Coding.

08-21-2008, 08:32 AM
#4
creativejen is offline creativejen
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
 
Posts: 2,353
iTrader: 25 / 96%
 

creativejen is an unknown quantity at this point

Send a message via MSN to creativejen

  Old

No. Do some research.

08-21-2008, 04:09 PM
#5
ibumoden is offline ibumoden
Status: I'm new around here
Join date: Jul 2008
Location:
Expertise:
Software:
 
Posts: 13
iTrader: 0 / 0%
 

ibumoden is on a distinguished road

  Old

Agree with enigma. I had to do this for a client once and from my hours of research online the method outlined by him is pretty much your only way.

08-21-2008, 11:17 PM
#6
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Originally Posted by shilpamg View Post
Please explain me that how can i pass a variable from javascript to PHP?
With an AJAX call. There is no way to do it otherwise because javascript runs after PHP is compiled on the server. It basically works like this:
Client Request -> Server processes request (PHP or other server side languages run here) -> Server sends output to browser -> Browser reads output (HTML, JS, ect.) -> Finished product

Therefore you are not able to send something backwards on the line.

08-25-2008, 07:03 AM
#7
shilpamg is offline shilpamg
Status: Member
Join date: Aug 2008
Location:
Expertise:
Software:
 
Posts: 101
iTrader: 0 / 0%
 

shilpamg is on a distinguished road

  Old

Originally Posted by ibumoden View Post
Agree with enigma. I had to do this for a client once and from my hours of research online the method outlined by him is pretty much your only way.
Ohhhh!

Not satisfactory Answer.

08-25-2008, 11:10 AM
#8
creativejen is offline creativejen
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
 
Posts: 2,353
iTrader: 25 / 96%
 

creativejen is an unknown quantity at this point

Send a message via MSN to creativejen

  Old

Originally Posted by shilpamg View Post
Ohhhh!

Not satisfactory Answer.
Read all the comments, villiage idiot explains it.

Understand this, "You can NOT do it the way you want to" !!

Use GOOGLE.COM to research!!!

It's not hard.

08-25-2008, 12:08 PM
#9
dynamic313 is offline dynamic313
Status: Junior Member
Join date: Jul 2008
Location:
Expertise:
Software:
 
Posts: 52
iTrader: 0 / 50%
 

dynamic313 is on a distinguished road

Send a message via MSN to dynamic313

  Old

Originally Posted by shilpamg View Post
Ohhhh!

Not satisfactory Answer.

Thats really quite ungratefull, many people posted answers that are 100% correct to help, just because it doesnt suit you isnt their fault they provided you with information that you could have easily found by using google.com i think a simple thank you would have been better

08-25-2008, 12:14 PM
#10
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old

Originally Posted by enigma View Post
Read all the comments, villiage idiot explains it.

Understand this, "You can NOT do it the way you want to" !!

Use GOOGLE.COM to research!!!

It's not hard.
But you were wrong. Village Idiot explained the only way was through AJAX, not via a redirect. Perhaps you should brush up on your research, or stop shoving that suggestion down others throats.

Regards,
Jeff

Closed Thread  
Page 1 of 2 1 2 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed