XCalibre3 Posted April 17, 2023 Share Posted April 17, 2023 Why isn't this working? echo" <br><br><button name='submit' class = 'btn' id='btn' onclick='hideButton()'>Click to Verify Information</button>"; echo" <br><br><button name='submit' class = 'btn' id='btn' onclick='hideButton()'>Click to Verify Information</button>"; THen Function: <script> function hideButton(){ document.getElementById('btn').style.display= 'none'; </script> the button does disappear but then comes back after a blink. So you can see if disappear. I'n lost on why it doesn't just stay gone. If you need more code just ask. Thank you! Quote Link to comment Share on other sites More sharing options...
maxxd Posted April 18, 2023 Share Posted April 18, 2023 What does "comes back after a blink" mean? First thing I notice is that you're missing a closing brace in your function. 1 Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted April 18, 2023 Share Posted April 18, 2023 Since the <button> doesn't have a "type" attribute, the default behavior is to submit the form. That's likely why the page is flashing and the button is redisplayed. You could try the following: echo" <br><br><button name='submit' type='button' class = 'btn' id='btn' onclick='hideButton()'>Click to Verify Information</button>"; More information about the <button> tag can be found here:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button With that said, I'm guessing the button is supposed to submit the form given it's named "submit". So you may need to tweak the JavaScript to submit the form if the verification process doesn't find any issues. 1 Quote Link to comment Share on other sites More sharing options...
XCalibre3 Posted April 18, 2023 Author Share Posted April 18, 2023 15 hours ago, maxxd said: What does "comes back after a blink" mean? First thing I notice is that you're missing a closing brace in your function. The button comes back. It should disappear. Quote Link to comment Share on other sites More sharing options...
XCalibre3 Posted April 18, 2023 Author Share Posted April 18, 2023 3 hours ago, cyberRobot said: Since the <button> doesn't have a "type" attribute, the default behavior is to submit the form. That's likely why the page is flashing and the button is redisplayed. You could try the following: echo" <br><br><button name='submit' type='button' class = 'btn' id='btn' onclick='hideButton()'>Click to Verify Information</button>"; More information about the <button> tag can be found here:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button With that said, I'm guessing the button is supposed to submit the form given it's named "submit". So you may need to tweak the JavaScript to submit the form if the verification process doesn't find any issues. This does nothing at all. I click the button and it just stays there as if I never clicked it. Quote Link to comment Share on other sites More sharing options...
Solution XCalibre3 Posted April 18, 2023 Author Solution Share Posted April 18, 2023 (edited) 3 hours ago, cyberRobot said: Since the <button> doesn't have a "type" attribute, the default behavior is to submit the form. That's likely why the page is flashing and the button is redisplayed. You could try the following: echo" <br><br><button name='submit' type='button' class = 'btn' id='btn' onclick='hideButton()'>Click to Verify Information</button>"; 15 hours ago, maxxd said: What does "comes back after a blink" mean? First thing I notice is that you're missing a closing brace in your function. This resolved the issue. Thank you both! It worked by putting the closing brace and changing type. Thanks much! I don't know who to mark as solution. Edited April 18, 2023 by XCalibre3 Quote Link to comment 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.