Erwin007 Posted May 6, 2023 Share Posted May 6, 2023 Hi, in my code I have this: <div class="col col-md-2 offset-md-7"> <label>Total Sales US$:</label> <input type="text" style="text-align:right;" name="total_am" value="<?php echo $total_am?>" class="form-control total"> </div> When $total_am is greater than 0 it has to hide the button tried this: <div class="col col-md-2 offset-md-7"> <label>Total Sales US$:</label> <input type="text" style="text-align:right;" name="total_am" value="<?php echo $total_am?>" class="form-control total"> <?php onoff(total_am); ?> </div> <script> function onoff(value) { if(value==="0") { document.getElementById('DeleteButton').hidden = true; } else { document.getElementById('DeleteButton').hidden = false; } } </script> But execution of the rest stops after getting to onoff(total_am) Trying for hours but can't get it to work Thanks Quote Link to comment https://forums.phpfreaks.com/topic/316262-hiding-a-button/ Share on other sites More sharing options...
Barand Posted May 6, 2023 Share Posted May 6, 2023 You can't call a javascript function from PHP. Javascript runs on the client after php has finished running on the server. Quote Link to comment https://forums.phpfreaks.com/topic/316262-hiding-a-button/#findComment-1608126 Share on other sites More sharing options...
Erwin007 Posted May 6, 2023 Author Share Posted May 6, 2023 Ok, that doesn't solve my problem unfortunately, still no clue how to get this done. Quote Link to comment https://forums.phpfreaks.com/topic/316262-hiding-a-button/#findComment-1608132 Share on other sites More sharing options...
Barand Posted May 6, 2023 Share Posted May 6, 2023 In your PHP code, if the total is 0, output the button, otherwise don't. Quote Link to comment https://forums.phpfreaks.com/topic/316262-hiding-a-button/#findComment-1608134 Share on other sites More sharing options...
Solution Erwin007 Posted May 6, 2023 Author Solution Share Posted May 6, 2023 Wow, it works!! Great! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/316262-hiding-a-button/#findComment-1608135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.