Custom Form

QuestionsCustom Form
Miguel asked 3 years ago

Hi,

I am using custom form and after submit changes on it changes not made in DB, just checked with firebug and no errors found.

This is form code:

<form name="client_form" method="post" action="" enctype="application/x-www-form-urlencoded" id="client_form">
<input type="hidden" name="id" value="">
<label for="Editbox5" id="Label11" style="position:absolute;left:9px;top:14px;width:46px;height:18px;line-height:18px;z-index:0;">Nombre:</label>
<input type="text" id="Editbox5" style="position:absolute;left:73px;top:14px;width:331px;height:18px;line-height:18px;z-index:1;" name="name" value="">
<input type="submit" id="savedata" name="" value="Save" style="position:absolute;left:73px;top:47px;width:96px;height:25px;z-index:2;">
</form>

I dont know what happen, any help appreciated

Thanks

Mike

2 Answers
Abu Ghufran answered 3 years ago

You need to add JS code along with html code.
Refer
jQuery("#savedata").click(function() { … });
and
jQuery("#insertdata").click(function() { … });

Miguel answered 3 years ago

Hi Abu,

Yes, Javascript is inserted, form post with no errors noticed by firebug.

<script type="text/javascript">

// load grid row in form
var load_form = function ()
{
var row = jQuery("#List3").jqGrid('getGridParam','selrow');
if(row)
{
jQuery("#List3").jqGrid('GridToForm',row,"#client_form");
}
else
{
alert("Please select Row")
}
}

// save form data to database using grid api
jQuery("#savedata").click(function()
{
var id = jQuery("#id").val();
if(id)
{
var grid = jQuery("#List3");

grid.jqGrid('FormToGrid',id,"#client_form");

// call ajax to update date in db
var request = '';
request = $('#client_form').serialize();
request += '&oper=edit&id='+id;

jQuery.ajax({
url: grid.jqGrid('getGridParam','url'),
dataType: 'html',
data: request,
type: 'POST',
error: function(res, status) {
jQuery.jgrid.info_dialog(jQuery.jgrid.errors.errcap,'<div class="ui-state-error">'+ res.responseText +'</div>',
jQuery.jgrid.edit.bClose,{buttonalign:'right'});
},
success: function( data ) {
// reload grid for data changes
grid.jqGrid().trigger('reloadGrid',[{jqgrid_page:1}]);
}
});

}
});

// save form data to database using grid api
jQuery("#insertdata").click(function()
{
var grid = jQuery("#List3");

// call ajax to update date in db
var request = '';
request = $('#client_form_add').serialize();
request += '&oper=add';

jQuery.ajax({
url: grid.jqGrid('getGridParam','url'),
dataType: 'html',
data: request,
type: 'POST',
error: function(res, status) {
jQuery.jgrid.info_dialog(jQuery.jgrid.errors.errcap,'<div class="ui-state-error">'+ res.responseText +'</div>',
jQuery.jgrid.edit.bClose,{buttonalign:'right'});
},
success: function( data ) {
// reload grid for data changes
grid.jqGrid().trigger('reloadGrid',[{jqgrid_page:1}]);
}
});
});

</script>

Thanks

Mike

Your Answer

16 + 6 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!