PHP - Moved: Javascript Toggle Divs Problem
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=348953.0 Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=310618.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=334294.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=316889.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=352475.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=306650.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=353367.0 Hi. I am looking for a way to have a button that toggles the background colour of my website. So for instance, I will have one button called 'switch to light', when its clicked it switches the colour of the background to a light colour, and another button replaces this that says 'switch to dark', and so on. I have turned to PHP because it appears to be the only way I would be able to have the change saved throughout the site, when pages are refreshed. However, I am a complete newbie, so have no idea what to do! Anyone that can help is a life saver! Thanks I'm trying to show my data under the toggle button according to the order_id. But i do not know why when i click on my toggle button it does not work. I do not know what is wrong with it. Any advice will be appreciated. <?php $dsql = "SELECT o.order_id , o.purchase_price , o.order_datetime, u.id, u.user_fullname , p.id, p.product_title , c.id , c.category, s.id , s.seller_fullname FROM ordered_items o INNER JOIN users u ON o.user_id = u.id INNER JOIN sellers s ON o.seller_id = s.id INNER JOIN products p ON o.product_id = p.id CROSS JOIN category c ON p.product_category = c.id WHERE category = '".$category."' ORDER BY o.order_id DESC"; $dquery = $conn->query($dsql); $tot_orders = mysqli_num_rows($dquery); if (!mysqli_num_rows($dquery)) { echo ' <div class="col-12"> <div class="badge badge-danger">No Orders Found</div> </div> '; } else { while ($drow = $dquery->fetch_assoc()) { ?> <tr> <td> #<?php echo $drow['order_id']; ?> </td> <td> <?php echo $drow['user_fullname']; ?> </td> <td> RM<?php echo number_format($drow['purchase_price'],2); ?> </td> <td class="text-center"> <a style="text-decoration: none;color: #000;" title="View Details" data-toggle="collapse" data-target="#products-details<?php echo $drow['order_id']; ?>"> <i class="nc-icon nc-minimal-down" onclick="changeToggleIcon(this)"></i> </a> </td> </td> </tr> <?php $p_sql = "SELECT o.order_id , o.purchase_price , o.order_datetime , o.quantity , o.quantity_unit, u.id, u.user_fullname , p.id, p.product_title , p.product_photo , c.id , c.category, s.id , s.seller_fullname FROM ordered_items o INNER JOIN users u ON o.user_id = u.id INNER JOIN sellers s ON o.seller_id = s.id INNER JOIN products p ON o.product_id = p.id CROSS JOIN category c ON p.product_category = c.id WHERE category = '".$category."'" ; $p_query = $conn->query($p_sql); while ($p_row = $p_query->fetch_assoc()) { ?> <tr class="collapse" id="products-details<?php echo $drow['order_id']; ?>" > <td style="border-top: none; font-size: 10px;"> <img src="https://dev.gopasar.today/images/product-main/<?php echo $p_row['product_photo']; ?>" style="height: 50px; width: 50px;"> </td> <th style="border-top: none; font-size: 10px;"> <?php echo $p_row['product_title']; ?> </th> <th style="border-top: none; font-size: 10px;"> Order Quantity :<?php echo $p_row['quantity']; ?><?php echo $p_row['quantity_unit']; ?> </th> <th style="border-top: none; font-size: 10px;"> RM <?php echo $p_row['purchase_price'];?> </th> </tr> </div> </div> </div> <?php } } } ?>
This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=325315.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=309516.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347290.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=356124.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=331343.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=355358.0 Hi All, I have a page where people can enter the name of food, like you would order in a restaurant (would appear on the menu). They can set if the food is gluten free, nut free, vegan etc. I am wanting to use buttons that can be clicked going red if they are not gluten free or not vegetarian and green if they are vegan or vegetarian. I have working code that does this but i dont feel like i am being efficient with how i am writing it as it is turning into a lot of repeated code. I would appreciate some help pointing me in the right direction. function popManageMenuModal($conn, $miid){ $stmt = $conn -> prepare(' SELECT menu_item_name, menu_item_is_vegan, menu_item_is_vegitarian, menu_item_is_gf, menu_item_is_nf, menu_item_is_df FROM ssm_menu_items WHERE menu_item_id = ? '); $stmt -> bind_param('i', $miid); $stmt -> execute(); $stmt -> bind_result($miname, $miisvegan, $miisveg, $miisgf, $miisnf, $miisdf); $stmt -> fetch(); if($miisvegan == '1'){ $vegansel = 'btn-success'; $vegan = 'Vegan'; $veganop = 'Is'; }else{ $vegansel = 'btn-danger'; $vegan = 'Vegan'; $veganop = 'Not'; } if($miisveg == '1'){ $vegsel = 'btn-success'; $vegi = 'Vegi'; $vegop = 'Is'; }else{ $vegsel = 'btn-danger'; $vegi = 'Vegi'; $vegop = 'Not'; } $output = ""; $output .= "<form><div class='form-group'><label>Menu Item Name</label><textarea class='form-control'>$miname</textarea></div>"; $output .= "<div class='form-inline'>"; $output .= "<div class='drButton btn $vegansel' data-value='$miisvegan'>{$veganop} {$vegan}</div>"; $output .= "<div class='drButton btn $vegsel' data-value='$miisveg'>{$vegop} {$vegi}</div>"; $output .= "<div>$miisvegan, $miisveg, $miisgf, $miisnf, $miisdf</div>"; $output .= "</form>"; return $output; } $(document).on('click','.drButton', function(){ var polarity = $(this).data("value") if(polarity == '0'){ $(this).addClass("btn-success") $(this).removeClass("btn-danger") $(this).data("value", '1') return } if (polarity == '1'){ $(this).addClass("btn-danger") $(this).removeClass("btn-success") $(this).data("value", '0') return } });
This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=354118.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=316624.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=346692.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=308032.0 Amazingly, PHP Coding Help is not the place to ask JavaScript questions. Mind blown. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=332796.0 |