CodeIgniter Forums
enable / disable button based on record inserted - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: General (https://forum.codeigniter.com/forumdisplay.php?fid=1)
+--- Forum: Lounge (https://forum.codeigniter.com/forumdisplay.php?fid=3)
+--- Thread: enable / disable button based on record inserted (/showthread.php?tid=71742)



enable / disable button based on record inserted - kvanaraj - 09-18-2018

I want to insert images into my db. once images uploaded view button, delete button to be enabled.
i try with anchor but 
Code:
<td align="center">
<a href="<?php echo base_url().'Users/deleteFile/'.$row['markid']; ?>"  name="idv"
 <i class="fa fa-remove" style="font-size:25px;color:red"></i>
</td>

Code:
<td align="center">
<a href="<?php echo base_url().'Users/viewfile/'.$row['markid']; ?>"  name="idv"
 <i class="fa fa-view" style="font-size:25px;color:red"></i>
</td>

how to solve this?


RE: enable / disable button based on record inserted - InsiteFX - 09-18-2018

Code:
DOM:
---------------------------------------------------

document.getElementById("myBtn").disabled = true;

buttonObject.disabled = true|false

JavaScript:
---------------------------------------------------

<div class="click">Click me to Disable/Enable a html button</div>
<div class="showup">
   <input id="Button" type="button" value=" + " style="background-color:grey" />
</div>

// Demo using plain javascript
var button   = document.getElementById("Button");
var clickBtn = document.getElementsByClassName('click')[0];

// Disable the button on initial page load
button.disabled = true;

//add event listener
clickBtn.addEventListener('click', function(event) {
   button.disabled = !button.disabled;
});

button.addEventListener('click', function(event) {
   alert('Enabled!');
});


CSS:
---------------------------------------------------

.showup {
   width: 100px;
   height: 100px;
}

.click {
   cursor: pointer;
   padding-bottom: 10px;
}

Try one of those


RE: enable / disable button based on record inserted - Wouter60 - 09-18-2018

First of all, your <a> tags aren't closed with </a>.
Question: Do you use AJAX to upload the images?


RE: enable / disable button based on record inserted - kvanaraj - 09-18-2018

(09-18-2018, 12:41 PM)Wouter60 Wrote: First of all, your <a> tags aren't closed with </a>.
Question: Do you use AJAX to upload the images?

yes i am using a ajax in a pop up window.


RE: enable / disable button based on record inserted - Wouter60 - 09-19-2018

Quote:yes i am using a ajax in a pop up window.

Make sure the buttons are disabled by default.
In the success part of your AJAX routine, enable the buttons. If you give both buttons the same css class, you can enable them in jQuery by removing the disabled property:
Code:
$('.image-action').prop('disabled', false);  //this will enable all elements with the "image-action" class.