EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: stephenl on July 01, 2018, 01:47:49 AM



Title: Obtain Data from a Form
Post by: stephenl on July 01, 2018, 01:47:49 AM
Hello

I have a datagrrid, which opens a form for user entery

This form has a button which i would like to use to run a piece of javascript, to select data based upon the data from a number of the form fields.

How would I get the data from the form fields ?

I have tried document.getElementById("Field Name") how this doesn't seem to work ?

Suggestions would be appreciated

Thank you



 


Title: Re: Obtain Data from a Form
Post by: jarry on July 01, 2018, 04:09:01 AM
Call the native 'serializeArray' method to get the form's data.
Code:
var data = $('#ff').serializeArray();
console.log(data);


Title: Re: Obtain Data from a Form
Post by: stephenl on July 01, 2018, 04:55:05 AM
Exactly what i was looking for - Thanks !


Title: Re: Obtain Data from a Form
Post by: stephenl on July 01, 2018, 05:30:17 AM
Next problem - How do I update a field value, on the form from Java


Title: Re: Obtain Data from a Form
Post by: jarry on July 01, 2018, 11:31:32 PM
Please try this code:
Code:
var data = $('#ff').serializeArray();
$.extend(data, {
  yourfield: 'new value'
});
$('#ff').form('load', data)


Title: Re: Obtain Data from a Form
Post by: stephenl on July 02, 2018, 12:30:02 PM
Great - Works as expected !

Thank You !