Connect with Expertise | Find Experts, Get Answers, Share Insights

A simple grid rows / columns.

C
 
Join Date: Oct 2007
Posts: 258
#1: Feb 8 '10
Hi all.

I need your help.

I realize this script and I do not know where to begin:

1) A simple grid rows / columns.
2) The first column contain an input type = "checkbox"
3) When select the input type, the line should change color than the other rows, and you should open a popup window.

For points 1, 2 you are OK.
Point 3 is the difficulty.

Suggestions?
Examples?

Kind regards
Viki

 
Join Date: Jan 2010
Posts: 16
#2: Feb 8 '10

re: A simple grid rows / columns.


This should get you going.

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function colorThisRow(row) {
  3.     if (document.getElementById("check" + row).checked) {
  4.         document.getElementById("row" + row).style.backgroundColor = "yellow";
  5.     } else {
  6.         document.getElementById("row" + row).style.backgroundColor = "white";
  7.     }
  8. }
  9. </script>
  10. <table border>
  11.     <tr id="row1">
  12.         <td>
  13.             <input type="checkbox" id="check1" onClick="colorThisRow(1)" />Click Me
  14.         </td>
  15.         <td>
  16.             Some stuff here1
  17.         </td>
  18.     </tr>
  19.     <tr id="row2">
  20.         <td>
  21.             <input type="checkbox" id="check2" onClick="colorThisRow(2)" />Click Me
  22.         </td>
  23.         <td>
  24.             Some stuff here2
  25.         </td>
  26.     </tr>
  27. </table>
  28.  
  29.  
  30.  
C
 
Join Date: Oct 2007
Posts: 258
#3: Feb 9 '10

re: A simple grid rows / columns.


Thanks x your answer.
This code work but open popup window when select the checkbox?
 
Join Date: Jan 2010
Location: New Zealand
Posts: 86
#4: Feb 9 '10

re: A simple grid rows / columns.


Specifically, what type of popup? Do you mean like a new window?
C
 
Join Date: Oct 2007
Posts: 258
#5: Feb 9 '10

re: A simple grid rows / columns.


Ok, yes new window popup when I select the checkbox.
thanks
 
Join Date: Jan 2010
Location: New Zealand
Posts: 86
#6: Feb 9 '10

re: A simple grid rows / columns.


A very easy way to do this would be to append this code to your checkbox function:

Expand|Select|Wrap|Line Numbers
  1. w=window.open();
  2. w.document.open();
  3. w.document.write("<h1>This is my popup!</h1><p>Put something meaningful here...</p>");
  4. w.document.close();
  5.  
PRO: Very flexible, widely supported
CON: Many browsers open this in a new tab and sometimes don't even give the tab focus!

I do assume that the simple alert(text), confirm(text) and prompt(text,value) methods are too simplistic for your needs?
C
 
Join Date: Oct 2007
Posts: 258
#7: Feb 9 '10

re: A simple grid rows / columns.


Ok, thanks x your help!
Reply