Ryan Bloom
Posts: 0
Joined: Tue Feb 12, 2013 6:24 pm

How to add two fields and display in text area?

Hello,

I am looking to add two fields upon value change. I have input fields "mp" & "ap". How do I have the total of the fields display in text area "totalprice"? Thank you!

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to add two fields and display in text area?

Read the values from input fields, then update the text area via JavaScript.

Ryan Bloom
Posts: 0
Joined: Tue Feb 12, 2013 6:24 pm

How to add two fields and display in text area?

Hi Max,

I am trying to do this but I am running into issues. My current code is:

var input = Tiggr('AP');
var input = Tiggr('MP');
alert( Number(MP) + Number(AP) );

I am trying to have them display in the text area "totalprice"

Any help would be very appreciated.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to add two fields and display in text area?

Tiggzi('component_name') returns the jQuery Mobile element. You need to add .val() for inputs or .text() for labels -- to get the actual value. It's jQuery and jQuery Mobile API: http://docs.tiggzi.com/javascript-api/. Tiggz(...) is just a small helper function, to get the element in the DOM.

So, in your case, it should be Tiggzi('AP').val();

Ryan Bloom
Posts: 0
Joined: Tue Feb 12, 2013 6:24 pm

How to add two fields and display in text area?

Hi Max,

When I use Tiggzi('AP').val(); it does not return anything. How do I have it add AP and MP upon value changes on the input fields? Thank you very much.

Ryan Bloom
Posts: 0
Joined: Tue Feb 12, 2013 6:24 pm

How to add two fields and display in text area?

I have also tried: Tiggzi('TotalCost').val()Tiggzi('AP').val()+Tiggzi('MP').val();

But that will not work either.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to add two fields and display in text area?

The component name is 'AP'? How or where do you invoke the JavaScript?

Ryan Bloom
Posts: 0
Joined: Tue Feb 12, 2013 6:24 pm

How to add two fields and display in text area?

I have Input component names: AP & MP and I have textare component: TotalPrice

I call javascript upon value change of MP & AP

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to add two fields and display in text area?

Try to run the JS on button click.

Ryan Bloom
Posts: 0
Joined: Tue Feb 12, 2013 6:24 pm

How to add two fields and display in text area?

I tried on button click but that did not work either.

Return to “Issues”