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
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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.