problem with using getElementById().getValue in FBJS/Facebook !

17,080

Instead of:

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

try using:

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

Are you using any JavaScript library, like jQuery or Prototype? If you're using jQuery:

newVal = $('#y257y').html();

Other suggestions:

Use hidden form element:

echo "<input type=hidden id=y257y value=\"$fdesc\">";

and in JavaScript:

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

Or just output a <script> tag:

echo "<script>newVal = \"$fdesc\";</script>";

and there's no need to find the value in the DOM – it's already in JavaScript.

Share:
17,080
Ahsan
Author by

Ahsan

Updated on July 20, 2022

Comments

  • Ahsan
    Ahsan almost 2 years

    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.

    - ahsan