Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getElementById – undefined

    I am using this code to generate hidden HTML code in Facebook :

    echo "<div id=\"y257y\" style=\"display:none;\">".$fdesc."</div>";

    And, I am trying to get this element back in JS using the following code

    newVal=document.getElementById('y257y').getValue();

    But, I am getting an error: Undefined

    Can anyone kindly help me out ?

    Thanks.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,516
    Thanks
    77
    Thanked 4,379 Times in 4,344 Posts
    Probably, it is getValue() that is undefined.

    Probably you need to use document.getElementById("y257y").innerHTML

    A <div> doesn't have a value. And even for elements that do have values, you would use .value and not .getValue()
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Regular Coder
    Join Date
    Sep 2011
    Posts
    103
    Thanks
    0
    Thanked 14 Times in 14 Posts
    Hi, You can use getElement by id as show below
    Code:
    document.getElementById("control.clientID").innerHTML


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •