0

here i am trying to get the value that is inside <td> value </td> using javascript getElementById(ID); but i am not able to fetch the value and display value in alert box.

code:

<script type="text/javascript">
function getvalue()
{
var lat = document.getElementById('lat').value;
var lon = document.getElementById('lon').value;
var lati = parseInt(lat);
var long = parseInt(lon);
alert(lati,long);
}
</script>

php-html code:

while($row = mysql_fetch_assoc($retval))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['theater_name'] . "</td>";
echo "<td>" . $row['address'] . "</td>";
echo "<td id='lat'>" . $row['lat'] . "</td>";
echo "<td id='lon'>" . $row['lon'] . "</td>";
echo "</tr>";
}

The table is auto generated by php from database table values for only one record. now i want to fetch lat and lon value in javascript and alert it.. but now i am not able to get alert...How can i do this?

1 Answer 1

4
var lat = document.getElementById('lat').innerHTML;
var lon = document.getElementById('lon').innerHTML;

value is for <form>s elements(<input>, <select> etc').

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.