aveeva Posted September 28, 2019 Share Posted September 28, 2019 I dont want unset onclick="this.disabled=true" if page refresh, code : <button type="button" class="addb btn btn-primary rounded-pill py-2 btn-block" type="submit" data-voice_sku="'.$row["voice_sku"].'" data-voice_name="'.$row["voice_name"].'" onclick="this.disabled=true">Add to Playlist</button> If page refresh onclick event unset. how to prevent? Quote Link to comment https://forums.phpfreaks.com/topic/309292-php-button-onclick%E2%80%9Cthisdisabledtrue%E2%80%9D-unset-if-page-refresh/ Share on other sites More sharing options...
Barand Posted September 28, 2019 Share Posted September 28, 2019 The onclick will still work after a refresh. Are you saying that you want disabled buttons to remain disabled after a refresh? Quote Link to comment https://forums.phpfreaks.com/topic/309292-php-button-onclick%E2%80%9Cthisdisabledtrue%E2%80%9D-unset-if-page-refresh/#findComment-1570029 Share on other sites More sharing options...
gw1500se Posted September 28, 2019 Share Posted September 28, 2019 Keep in mind that PHP is stateless. That means each time the page is output by the server it is as if it is the first time and nothing about what happened on that page previously is known. What Barand is trying to get at, is whether or not you need to use a session variable to keep track of the state of that button. Quote Link to comment https://forums.phpfreaks.com/topic/309292-php-button-onclick%E2%80%9Cthisdisabledtrue%E2%80%9D-unset-if-page-refresh/#findComment-1570030 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.