1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Using Javascript and PHP

Discussion in 'JavaScript' started by vijaykoul, Feb 8, 2005.

  1. #1
    Hi everybody,

    I want a value calculated in Javascript to be used in PHP b'coz that value
    will act as an argument for the function defined in PHP. Can I do it

    If yes, how?

    One thing I want to tell is that that function is to be defined in PHP only and not i Javascript.

    In short can I use a value calculated variable of Javascript in PHP.

    It is urgent...
    Need help.

    Thanx
    VJ
     
    vijaykoul, Feb 8, 2005 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Not directly... JavaScript is client-side and PHP is server-side. The best you would be able to do is calculate whatever you want to calculate in JavaScript, then have the JavaScript trigger the loading of a page with that value within the URL (or a field in a form post) so PHP could evaluate it.
     
    digitalpoint, Feb 8, 2005 IP
  3. Josh

    Josh Peon

    Messages:
    893
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes, the way Shawn just mentioned is about the only way to do it.

    i.e. have the javascript do a window.location = 'file.php?varible=thevar' and have the PHP file use $_GET['varible'] to get it..


    Josh
     
    Josh, Feb 8, 2005 IP
  4. vijaykoul

    vijaykoul Guest

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    the problem now is that all the values i have calculated in Javascript have to be passed to a Payment gateway file and hence i dont think i wil be able to $_GET them.

    any other alternative
     
    vijaykoul, Feb 9, 2005 IP
  5. dtan

    dtan Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    couldn't you write a wrapper file that would simply retrieve the get or post value and then call or include the necessary file?
     
    dtan, Mar 12, 2005 IP