Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'll explain a little bit more.</p> <p>I have a JQuery datatable, and through CSS I have different <code>&lt;tr classes&gt;</code>. Depending on the information stored in the database, these <code>&lt;tr&gt;</code> get a different class, thus a different color in the datatable.</p> <p>Now for one <code>&lt;tr class&gt;</code> I'd like to give the user the option to hide/show. I was thinking to do this with a checkbox, and the javascript would parse an url when checked, and remove it when unchecked again. This URL can be used for php to run different queries, if <code>$_GET['parsedurl']</code>: query to show all tables, elseif <code>$_GET['empty']</code>: query for not showing that 1 information.</p> <p>But this is the worst way to do it. I need to find something to toggle the <code>display: none</code> on or off of the table class, since this is working client-side.</p> <p>So Im now thinking to keep the parsing of the javascript in an URL and depending on the URL, I run the .php GET to echo out <code>&lt;tr style: display: none&gt;</code> or just simply <code>&lt;tr&gt;</code></p> <p>Therefore I need some javascript which does this:</p> <ul> <li>If checkbox is checked, redirect to projectlist.php?showpastdate</li> <li>When URL = projectlist.php?showpastdate, make checkbox checked.</li> <li>When URL = projectlist.php?showpastdate and checkbox gets unchecked, redirect to projectlist.php, where the checkbox is unchecked.<br /></li> </ul> <p>I think these triggers are the best options?</p> <p>With .PHP I'll do:<br /></p> <pre><code>if (isset($_GET['showpastdate'])) { &lt;tr style: display: none&gt; } else { &lt;tr&gt; } </code></pre> <p>Maybe someone has an even better solution? I'd like to hear!</p> <p>Thanks.</p> <p><strong>EDIT</strong></p> <p>The javascript I now have is:</p> <pre><code>&lt;script&gt; function toggleAutoRefresh(cb) { if (cb.checked) { window.location.replace("?showpastdate"); } // If a checkbox named "cb" is checked, and the url contains "?showpastedate" if ((cb.checked) &amp;&amp; !~window.location.href.indexOf("?showpastdate")) { //Uncheck the checkbox and remove the "?showpastedate" from the url document.getElementById("showpastdate").checked = false; window.location.href.replace("?showpastdate",""); } else { // Else, check the checkbox and add the "?showpastedate" to the url document.getElementById("showpastdate").checked = true; window.location.href += "?showpastdate"; } } &lt;/script&gt; </code></pre> <p>After checking the checkbox, it goes to the page projectlist.php?showpastdate and gets unchecked there. When checking again, it goes to projectlist.php?showpastdate?showpastdate. It should remove the ?showpastdate, not add another.</p> <p>This is could do with PHP too, but I really don´t like a submit button for this checkbox. Just check and execute.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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