Reputation Activity
-
chris92 reacted to Lyndsey in Change the value of a html element using jquerySomething like this? http://jsfiddle.net/LyndseyB/8fe7F/
I've added a container div and some classes so that you can basically duplicate your HTML to another select element and also validate that with the same code.
Hope it helps.
-
chris92 reacted to Chris Day in jQuery toggle() on array of mysql fetched arrray<table> <?php $cat_set = get_all_cats(); while($category = mysql_fetch_array($cat_set)){ if($category["category"] != "no-cat"){ echo " <tr data-show=\"".$category["category"]."\"> <td id=\"cats\">".$category["category"]."</td> <td><img id=\"blink\" src=\"drop.png\"></td> </tr>"; $course_set = get_courses_for_cats($category["cat_id"]); while ($course = mysql_fetch_array($course_set)) { echo" <tr class=\"cont\" data-cat=\"".$category["category"]."\"> <td><input value = ". $course["course_code"] ." name=\"boxes[]\" type=\"checkbox\" /></td> <td class=\"code\">" . $course["course_code"] . "</td> </tr>"; } } else { $course_set = get_courses_for_cats($category["cat_id"]); while ($course = mysql_fetch_array($course_set)) { echo" <tr class=\"cont\" data-cat=\"".$category["category"]."\"> <td><input value = ". $course["course_code"] ." name=\"boxes[]\" type=\"checkbox\" /></td> <td class=\"code\">" . $course["course_code"] . "</td> </tr>"; } } } ?> </table> <script> $(document).ready(function(){ $(".cont").hide(); $("[data-show]").click(function(){ var selector = $(this).attr("data-show"); $("[data-cat='"+selector+"']").toggle(); }); }); </script> -
chris92 reacted to Lyndsey in jQuery toggle() on array of mysql fetched arrrayHiya,
When posting code, ensure you use the code tags as it's a lot easier for us to read
I'd probably use some classes and data attributes. Something like this:
http://jsfiddle.net/LyndseyB/LfA8Q/
However, you'd probably be better off not using a table and using some divs. Would be easier to target elements without using multiple classes etc.
Hey Chris, code tags are located on the text editor (circled below):
Hope this helps.