?
Solved

Capture content of a <TD>  with onClick event.

Posted on 2003-03-17
3
Medium Priority
?
400 Views
Last Modified: 2008-02-01
Hi!

I just caught a posting from 'COBOLdinosaur' which was a 'fake' select form element (code posted below).  The trick was that it was a table which seems to be nested in a div. Now my problem is that i do NOT need a fake form element but i really do want to develop an calender in which you can drag your workingtime. Now i know you probable think that it's best to use a <SELECT> element for that but those just can't be as flexible as the good ol' tables. Pleas how can i use the code below so that i can select ,multiple, options with the CTRL and/or SHIFT key to select multiple <TD> elements and how can i get those posted to another proccesing page ??

Hope you can help me out.

code:
-----

<HTML>
<head>
<STYLE>
  .selectBOX {border:3px ridge #dddddd;height:75;width:125;overflow-y:scroll;
              border-right:3px double #bbbbbb; border-bottom:3px double #bbbbbb;}
   
  .hiliteON {color:white;background-color:navy;font-family:arial;font-size:10pt}
  .hiliteOFF {color:black;background-color:white;font-family:arial;font-size:10pt}
</STYLE>
<script language="JavaScript">
<!--
  var lastone=false;
  function chgcls(EL)
  {
     if (lastone)
     {
        lastone.className="hiliteOFF";
     }
     lastone=EL;
     lastone.className="hiliteON"
  }
//-->
</script>
</HEAD>
<BODY>
<h1 align="center"> Fake Form Elements </h1>
<div class="textBOX" STYLE="position:absolute;left:165;top:73">
fake
</div>
<div class="selectBOX" style="position:absolute;left:165;top:115">
  <table border=0 cellspacing=0 cellpadding=0>
     <tr><td class="hiliteOFF" onClick="chgcls(this)">Alberta</td></tr>
     <tr><td class="hiliteOFF" onClick="chgcls(this)">Ontario</td></tr>
     <tr><td class="hiliteOFF" onClick="chgcls(this)">Quebec</td></tr>
     <tr><td class="hiliteOFF" onClick="chgcls(this)">Newfoundland</td></tr>
     <tr><td class="hiliteOFF" onClick="chgcls(this)">all fake</td></tr>
  </table>
</div>
<!--
  Note:
       Even though the fake select is not a functional form element, we
       could still capture the cell value with the onClick event and use
       it for processing
-->
</BODY>
</HTML>
0
Comment
Question by:M00nsh1n3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
ngrover earned 300 total points
ID: 8153164
Just change the script so that you don't turn off the last one selected.  You might want to change the first line to be:

if(EL == lastone) instead of if(lastone);

that way you can turn it off by clicking the same one again.  Then modify whatever script is handling the application of the selected box to handle applying multiple selected boxes.


Hope this helps.  

Nate Grover
http://www.nategrover.com
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10131420
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: ngrover {http:#8153164}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question