SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Inside a table

  1. #1
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inside a table

    this code outputs to another page showing what coordinates i have clicked but i just want to be able to only click inside a table, but it lets me click outside the table how do i only allow it inside a table?

    Code:
    <table border="1" width="100" height="100" id="table1">
    	<tr>
    		<td><script language="javascript" type="text/javascript">
    document.onclick = function(e){
    		var e 		= e ? e : window.event;
    		var x = e.screenX;
    		var y = e.screenY;
    		document.location = 'nextpage.php?x=' + x + '&y=' + y;
    	}
    </script></td>
    	</tr>
    </table>
    Animated Chatrooms - www.121chatrooms.net

  2. #2
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    St Petersburg, Russia
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try to rewrite it this way:
    document.getElementById('table1').onclick = ...

  3. #3
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    didnt seem to work i click anywhere nothing happenes even inside the table this is the code:

    Code:
    <table border="1" width="100" height="100" id="table1">
    	<tr>
    		<td><script language="javascript" type="text/javascript">
    document.onclick = function(e){
    		var e 		= e ? e : window.event;
    		var x = e.screenX;
    		var y = e.screenY;
    		document.getElementById('table1').onclick = 'nextpage.php?x=' + x + '&y=' + y;
    	}
    </script></td>
    	</tr>
    </table>
    Animated Chatrooms - www.121chatrooms.net

  4. #4
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?
    Animated Chatrooms - www.121chatrooms.net

  5. #5
    SitePoint Addict
    Join Date
    Apr 2006
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try putting the function up in the <head> tags and put the "onClick" on the table/table cell, having it trigger the function.

  6. #6
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    didnt work this is the code i got:

    Code:
    <html>
    <head>
    <script language="javascript" type="text/javascript">
    document.onclick = function(e){
    </head>
    <body><div align="left">
    			<table border="1" cellpadding="0" cellspacing="0" width="50" height="50">
    				<tr>
    					<td>
    							var e 		= e ? e : window.event;
    		var x = e.screenX;
    		var y = e.screenY;
    		document.getElementById('table1').onclick = 'nextpage.php?x=' + x + '&y=' + y;
    	}
    	</script>
    					</td>
    				</tr>
    			</table>
    		</div>
    </body>
    </html>
    blank page.
    Animated Chatrooms - www.121chatrooms.net

  7. #7
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is another code i got still not working

    Code:
    <table id="table1" border="1" width="100" height="100">
    	<tr>
    		<td><script language="javascript" type="text/javascript">
    document.onclick('table1') = function(e){
    		var e 		= e ? e : window.event;
    		var x = e.screenX;
    		var y = e.screenY;
    		document.location = 'nextpage.php?x=' + x + '&y=' + y;
    	}
    </script></td>
    	</tr>
    </table>
    Animated Chatrooms - www.121chatrooms.net


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •