Jump to content

Making a table clickable?


Rommeo

Recommended Posts

I have many tables as a result of search query.. and tables keeps photos and texts. and I m trying to make the table clickable as you move the cursor anywhere on the table and you will be able to click even for the areas that has no text.

 

Is it possible to do this ?

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/182822-making-a-table-clickable/
Share on other sites

Page taken down.

 

Code:

<table border="1" cellspacing="0" cellpadding="20">
<tr>
	<td onClick="alert('Item 1 Row 1');">Item 1 Row 1</td>
	<td onClick="alert('Item 2 Row 1');">Item 2 Row 1</td>
</tr>
<tr>
	<td onClick="alert('Item 1 Row 2');">Item 1 Row 2</td>
	<td onClick="alert('Item 2 Row 2');">Item 2 Row 2</td>
</tr>
</table>

<br>

<table border="1" cellspacing="0" cellpadding="15">
<tr onClick="alert('Table 2 Row 1 Click');">
	<td>Item 1 Row 1</td>
	<td>Item 2 Row 1</td>
</tr>
<tr onClick="alert('Table 2 Row 2 Click');">
	<td>Item 1 Row 2</td>
	<td>Item 2 Row 2</td>
</tr>
</table>

<br>

<table border="1" cellspacing="0" cellpadding="10" onClick="alert('Table 3 Click');">
<tr>
	<td>Item 1 Row 1</td>
	<td>Item 2 Row 1</td>
</tr>
<tr>
	<td>Item 1 Row 2</td>
	<td>Item 2 Row 2</td>
</tr>
</table>

yes, that is entirley possible or you could create a function in html script tags at the top of the page specifying the javascript type and then just reference the single function that way.

 

If you want to leant javascript then visit w3schhols.com and click the link for Javascript and it will tell you everything that you need to know and more that you dont :P.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.