calling a javascript variable with php?

Discussion in 'PHP' started by pHrEaK, Mar 24, 2011.

  1. #1
    Hello all, I have a question concerning variable interpretation. What i'm wanting to do is create a simple search engine. The user will enter a string of text into an input box and on submit the inputted string will be sent to a javascript function. That function will then set a variable equal to the users string. My question related to php is, how would you use php to call the javascript variable? I'm pretty new to php and not sure if i would just be able to do all of this with php and cut out the javascript? Any how once the variable is set to where i can work with it in php i'll then compare that variable to records of a set attribute in a table of the database....in theory creating a simple search function....what do you guys think?
     
    pHrEaK, Mar 24, 2011 IP
  2. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #2
    echo "<script>var variable_name = 'value';</script>";
     
    tvoodoo, Mar 24, 2011 IP
  3. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #3
    tvoodoo I think he wants to know how to get javascript variable content into php variable. Just send request via ajax or so, there are no more ways how to do it
     
    G3n3s!s, Mar 25, 2011 IP
  4. pHrEaK

    pHrEaK Active Member

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Thanks for the reply's guys. So I'm going to have to do some research on ajax I guess. Thanks for pointing me in the right direction
     
    pHrEaK, Apr 11, 2011 IP