EasyUI Forum
March 28, 2024, 11:15:27 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Obtain Data from a Form  (Read 5197 times)
stephenl
Newbie
*
Posts: 30


View Profile
« 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



 
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 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);
Logged
stephenl
Newbie
*
Posts: 30


View Profile
« Reply #2 on: July 01, 2018, 04:55:05 AM »

Exactly what i was looking for - Thanks !
Logged
stephenl
Newbie
*
Posts: 30


View Profile
« Reply #3 on: July 01, 2018, 05:30:17 AM »

Next problem - How do I update a field value, on the form from Java
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #4 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)
Logged
stephenl
Newbie
*
Posts: 30


View Profile
« Reply #5 on: July 02, 2018, 12:30:02 PM »

Great - Works as expected !

Thank You !
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!