getting value of html element using its id in php

Discussion in 'PHP' started by learnerabn, Oct 11, 2010.

  1. #1
    Hi all,

    I want to get the value of an html element using its id.
    I want to do this using php not in javascript(even though i know that php is server side scripting it has nothing to do with client scripting)...
    Is this possible?
    If possible means how?

    Thanks in advance...
     
    learnerabn, Oct 11, 2010 IP
  2. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #2
    Impossible.
     
    ActiveFrost, Oct 11, 2010 IP
  3. pro-php-developer

    pro-php-developer Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Let us try something unconventional.To start with , y do u want this?..anyway you will want to take the HTML to server(or say PHP) first either using conventional POSTing or AJAX or something
     
    pro-php-developer, Oct 13, 2010 IP
  4. TYPELiFE

    TYPELiFE Peon

    Messages:
    109
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    TYPELiFE, Oct 14, 2010 IP
  5. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #5
    No one ( if I haven't misunderstood OPs question ) is talking about the ability to parse HTML but to get input field values entered by the end user, which doesn't exist until the file have been written or data sent somewhere via GET or POST.
     
    ActiveFrost, Oct 14, 2010 IP
  6. JoelLarson

    JoelLarson Peon

    Messages:
    61
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I'm agreeing with ActiveFrost and saying it's not possible in PHP due to it being server-side.



    In Javascript, the scenario is created with:
    document.getElementById('example');
    Code (markup):
    In PHP, the only way to get the #example id is if it's a form field and "example" is the name attribute. (Retrieved with $_REQUEST['example'])
     
    JoelLarson, Oct 14, 2010 IP
  7. SamT

    SamT Peon

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You answered your own question, due the fact PHP runs on the server before you even see the document and the http protocol stateless, it is impossible to do without JavaScript.
     
    SamT, Oct 14, 2010 IP
  8. pro-php-developer

    pro-php-developer Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Okay Sam. Tell me what exactly the situation. There is always a solution in technology ;)
     
    pro-php-developer, Oct 15, 2010 IP
  9. SamT

    SamT Peon

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Just what you suggested, AJAX. Sent your content via an asynchronous request in JavaScript to a PHP reviver script, then do what you wish with it.
     
    SamT, Oct 16, 2010 IP
  10. pro-php-developer

    pro-php-developer Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    yep.we are done:).now just need to find out the logic for manipulating the script..I mean the HTML.And that was u were looking for?
     
    pro-php-developer, Oct 16, 2010 IP