I want to attach a function to my submit button. But my code doesn't seem to be calling the function.
Basically what I want it to do is, enabling all disabled field when the form is being submitted.
This below is my code:
<script>
function enableField() {
$("#Booking_clientPackagedService_id").prop("disabled", false);
}
</script>
<?php
echo CHtml::submitButton(Yii::t('app', 'Save'));
$this->endWidget();
?>
This #Booking_clientPackagedService_id
initially is disabled after certain action being done. But when I click on submit, I would like to enable the field. How can I do it? Please advise, thanks! :D
EDIT
So I've removed onclick
event on my submit button and added as per Kancho Iliev's comment.
$( "#booking-form" ).submit(function() {
$("#Booking_clientPackagedService_id").prop("disabled", false);
});
But it is still not working. Where have I missed out?
Remove onclick event, and add
$("your_form_name").submit(function(){
enableField();
});
This is the correct way of attaching a submit function:
$(function() {
$("#formName").submit(function() {
alert("hi");
//do whatever
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.