PHP in javascript

Discussion in 'PHP' started by Triexa, May 16, 2007.

  1. #1
    Ugh I've been working too much today. Just can't think anymore... and now this is bothering me. Say I had the following JS:

    for (i = 0; i < elements.length; i++) {
        alert(elements[i].value);
    }
    Code (markup):
    how could I deal with the elements.value in PHP? I guess, how can I "inline-pass" that variable to some code?
     
    Triexa, May 16, 2007 IP
  2. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Pass this value in GET method to the php file.
     
    Subikar, May 16, 2007 IP
  3. SeLfkiLL

    SeLfkiLL Active Member

    Messages:
    85
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    50
    #3
    SeLfkiLL, May 16, 2007 IP
  4. bibel

    bibel Active Member

    Messages:
    289
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #4
    serialize the array, than pass to the next page with GET, then unserialize
     
    bibel, May 17, 2007 IP
  5. Mr D

    Mr D Peon

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    javascript is serverside so you can use ajax or just echo the whole array somewhere between you script tags
     
    Mr D, May 17, 2007 IP
  6. bibel

    bibel Active Member

    Messages:
    289
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #6
    ouch .... typo ... err .... ROLF
     
    bibel, May 17, 2007 IP
  7. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    #7
    is javascript serverside!?!?!?!?!
    i know that it is client side program :)
     
    coderbari, May 19, 2007 IP
  8. DeViAnThans3

    DeViAnThans3 Peon

    Messages:
    785
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Javascript could be serverside, but usually nobody works with it serverside but only clientside. See wikipedia article about SSJS.

    Triexa; like said above, you could pass it via GET to a script, you could use AJAX. There is also a possibility to POST data to a script, however I never used that method, so I don't know whether or not it works very well.
     
    DeViAnThans3, May 20, 2007 IP