Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Capture content of a <TD>  with onClick event.

Posted on 2003-03-17
3
Medium Priority
?
401 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
2 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

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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

564 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