CodeIgniter Forums

Full Version: enable / disable button based on record inserted
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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
First of all, your <a> tags aren't closed with </a>.
Question: Do you use AJAX to upload the images?
(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.
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.