How do I get the value of FORM fields when executing Javascript from a Button?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

How do I get the value of FORM fields when executing Javascript from a Button?

Post by Jaymer »

Go to a Form.
Add a new button in a form cell which does "execute javascript".

In that JS, I want to call a function, but I need the values of form fields.
having trouble with syntax.

cant use the usual suspects:
<<Cust.CustNum>>
{Cust.CustNum}
data["Cust.CustNum"]

tried var tag = parser.getField ("CustNum").getValue (); but "parser" is unknown. This is normally used in a Render script.

Plenty of examples for getting this in a Grid using the "parser" object.
Pretty sure I've done this before... just can't find it.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: How do I get the value of FORM fields when executing Javascript from a Button?

Post by hpl123 »

I often use jQuery for things like that. To do this in Aware, set an ID for the input (myformfield) and then use this script:

Code: Select all

var myformfield = $('#myformfield').val();
Henrik (V8 Developer Ed. - Windows)
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How do I get the value of FORM fields when executing Javascript from a Button?

Post by Jaymer »

I thought this was going to work, but there is no place for me to enter a cell id.

I am on a form.
the form has a child reference field "om_images"
the images are in a custom layout
there are right-click operations defined in "operations with records" - this creates a pop-up menu on right-click on PC and also works nicely on tablet.
one of those operations uses "Execute Javascript" where I want to call a script and I need access to fields in that BO's instance.

"parser" is unknown, i assumed because I wasn't in a traditional grid.
But i guess I'm not in a traditional form either.

@Support surely should know how?
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jhstephenson
Posts: 297
Joined: Wed Apr 22, 2015 11:44 pm

Re: How do I get the value of FORM fields when executing Javascript from a Button?

Post by Jhstephenson »

Was there ever been an answer for this?
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How do I get the value of FORM fields when executing Javascript from a Button?

Post by Jaymer »

Jim, I don’t think I got a specific answer.
I think I just changed what I was doing, but it was so long ago, I can barely think of which app this was about.
But it depends on if you’re trying to get access to a field on a form or in a grid, because the syntax is different.
Perhaps you might need to start a new post with your exact situation.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Post Reply