Getting a value from a HTML table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Milan
Forum Commoner
Posts: 97
Joined: Wed May 17, 2006 6:08 pm

Getting a value from a HTML table

Post 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!
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you could use a hidden form field, or you can use innerHTML to fetch the contents of any html element.
Milan
Forum Commoner
Posts: 97
Joined: Wed May 17, 2006 6:08 pm

Post by Milan »

can you give me a simple example please?

thanks!
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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()">
Milan
Forum Commoner
Posts: 97
Joined: Wed May 17, 2006 6:08 pm

Post by Milan »

Lol i was expecting like at least 50 lines of code.

Once again - you know the knowledge!

thanks
Post Reply