My Aim – User enters ClientName into autocomplete and selects ClientName. On selection, Apply button gets enabled.
On Apply button click, submit ClientName and ClientId to different PHP page.
My Problem – All works Ok, but does not redirect/post to the page url in the form action.
Can anyone help, many thanks.
$(function() {
$("#btnCancelId").button();
$("#btnApplyId").button();
$('#btnApplyId').attr('disabled', true);
$("#btnAddId").button();
$('#btnAddId').click(function() {$divDialog.dialog('open'); return false;});
$('#txtClientName').bind('keyup', function() {
$('#txtClientId').val('');
$('#txtClientId').css({'background-color': '#FFC0C0'});
$("#btnApplyId:eq(0)").addClass("ui-state-disabled").attr("disabled", true);
});
var $divDialog = $('#divDialog');
$divDialog.dialog({
autoOpen: false,
modal: true,
title: 'Company name',
buttons: [{
id: 'btnCancelId',
text: 'Cancel',
click: function() {$divDialog.dialog('close');}
},{
id: 'btnApplyId',
text: 'Apply',
disabled: true,
click: function() {
$('#divDialog').submit();
// $divDialog.dialog('close');
}
}]
});
$("#txtClientName").autocomplete({
source: "_ajcustlist.php",
minLength: 2,
select: function(event, ui) {
$("#btnApplyId:eq(0)").removeClass("ui-state-disabled").attr("disabled", false);
$('#txtClientId').val(ui.item.id);}
});
});
The Html code is –
<div id="divDialog">
<form id="client_form" name="client_form" method="post" action="editinv.php">
<input type="text" id="txtClientName" name="txtClientName" />
<input type='text' id='txtClientId' name='txtClientId' style='display:none'/>
</form>
</div>
The click event in your dialog action button is wrong. It’s currently trying to submit a div (
$('#divDialog')) instead of the form ($('#client_form')) within the div.Change:
to: