Note that there are some explanatory texts on larger screens.

plurals
  1. POtarget the parent row of a particular cell
    text
    copied!<p>I have a table with a list of records. each row has class "list_request" and has a cell of class "record_approval":</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;th&gt;name&lt;/th&gt;&lt;th&gt;date&lt;/th&gt;&lt;th&gt;id&lt;/th&gt;&lt;th&gt;group&lt;/th&gt;&lt;th&gt;approval&lt;/th&gt; &lt;tr class="list_request"&gt; &lt;td&gt;Frank&lt;/td&gt;&lt;td&gt;2012-2-15&lt;/td&gt;&lt;td&gt;01&lt;/td&gt;&lt;td&gt;Account&lt;/td&gt;&lt;td class="record_approval"&gt;Dave Ellis&lt;/td&gt; &lt;/tr&gt; &lt;tr class="list_request"&gt; &lt;td&gt;Ellen&lt;/td&gt;&lt;td&gt;2012-2-19&lt;/td&gt;&lt;td&gt;04&lt;/td&gt;&lt;td&gt;Admin&lt;/td&gt;&lt;td class="record_approval"&gt;Susan Peters&lt;/td&gt; &lt;/tr&gt; &lt;tr class="list_request"&gt; &lt;td&gt;Michael&lt;/td&gt;&lt;td&gt;2012-2-26&lt;/td&gt;&lt;td&gt;06&lt;/td&gt;&lt;td&gt;Admin&lt;/td&gt;&lt;td class="record_approval"&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p></p> <p>I'd like to construct a javascript function that checks whether or not "record_approval" has a value (which value is unimportant), and if so, change the css color value for that row. Essentially, the approved records should have a different color than the unapproved ones. something like...</p> <pre><code>function check_approval(){ var checkrow = document.querySelectorAll( "tr.request_list" ) var checkcell = document.querySelectorAll( "td.record_approval" ) for (i=0;i&lt;checkcell.length;i++){ if (!checkcell.value){ this.parentNode.style.color = "ff9900"; } else{ } } </code></pre> <p>is this essentially the wrong approach?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload