Page 1 of 1

Getting a value from a HTML table

Posted: Thu May 25, 2006 11:40 am
by Milan
I have the following problem,

I added a small script that can open (show) a layer with a hint when mouse is over it, i would like to use it to display currency rate on the website but since the list of products is generated from a mySQL table every time $price will always change till it reaches the last record in the table.

Is there a way for me to read a value from a HTML table cell or can i place a hidden field somewhere to populate the price so i can retreeve it once the mouse is over it?

any help will be appriciated.

thanks!

Posted: Thu May 25, 2006 1:18 pm
by Burrito
you could use a hidden form field, or you can use innerHTML to fetch the contents of any html element.

Posted: Thu May 25, 2006 3:59 pm
by Milan
can you give me a simple example please?

thanks!

Posted: Thu May 25, 2006 4:31 pm
by Burrito

Code: Select all

<script>
function blah()
{
    alert(document.getElementById('something').innerHTML);
}
</script>
<table>
  <tr>
    <td id="something">
      some text in here
    </td>
  </tr>
</table>
<input type="button" value="click me" onClick="blah()">

Posted: Thu May 25, 2006 6:06 pm
by Milan
Lol i was expecting like at least 50 lines of code.

Once again - you know the knowledge!

thanks