1

how can i remove disabled attribute from continue button when submit button is clicked or form submitted, it removes the disabled attribute from continue button when submit is clicked. but the problem is when you click on submit button it refreshes the pages so continue button again rollbacked to disabled state:

this is my view

<?php echo form_open('admin/requests/approve_request/'.$this->uri->segment(4)); ?>
    <div class="form-group">
        <label for="pending_reason">Note</label>
        <textarea class="form-control"  name="pending_reason"rows="6">
            <?php echo set_value('pending_reason'); ?>
        </textarea>
        <?php echo form_error('pending_reason'); ?>
    </div>

    <button type="submit" class="btn btn-success" value="submit" id="submit" disabled>Submit</button>
</form>

<button type="button" class="btn btn-success" id="continue" disabled>Continue</button>

an my js is

<script>
    $("#submit").click(function() {
        $("#continue").removeAttr('disabled', true);
    });

    });
</script>
Alan Larimer
  • 589
  • 8
  • 24
turaco
  • 67
  • 10
  • and this is not fully working for me – turaco Oct 02 '17 at 13:31
  • Mark this with PHP tag as well since you are using it. Generally, when you click submit, the page should not reload. Alternatively, you can follow this https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events and react to event from server that form has been recieved – DanteTheSmith Oct 02 '17 at 13:31
  • can't you handle on client side? – turaco Oct 02 '17 at 13:36
  • Possible duplicate of [Remove disabled attribute using JQuery?](https://stackoverflow.com/questions/13626517/remove-disabled-attribute-using-jquery) – DFriend Oct 02 '17 at 14:24

1 Answers1

0

Take off the type="submit" property and that should fix your problem.

Miguel Coder
  • 1,896
  • 19
  • 36
  • so how to submit form by removing type="submit"? – turaco Oct 02 '17 at 13:41
  • An Ajax request would be the best way to do that. It's easy if you have JQuery. – Miguel Coder Oct 02 '17 at 13:42
  • 1
    yes but resolved on client side like this $('form').submit(function(){ $(this).find('#continue_to_send').prop('disabled', true); return true; // return false stops the from from actually submitting.. this is only for demo purposes }); – turaco Oct 02 '17 at 13:52
  • I suppose that is another way of doing it. Thanks for the insight. I feel like I have learned something new today. :) – Miguel Coder Oct 02 '17 at 21:17