Page 1 of 3

How to add two fields and display in text area?

Posted: Tue Feb 12, 2013 6:24 pm
by Ryan Bloom

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!


How to add two fields and display in text area?

Posted: Tue Feb 12, 2013 7:41 pm
by maxkatz

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


How to add two fields and display in text area?

Posted: Wed Feb 13, 2013 10:11 pm
by Ryan Bloom

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.


How to add two fields and display in text area?

Posted: Thu Feb 14, 2013 2:51 am
by maxkatz

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();


How to add two fields and display in text area?

Posted: Thu Feb 14, 2013 5:07 am
by Ryan Bloom

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.


How to add two fields and display in text area?

Posted: Thu Feb 14, 2013 5:14 am
by Ryan Bloom

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

But that will not work either.


How to add two fields and display in text area?

Posted: Thu Feb 14, 2013 5:51 am
by maxkatz

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


How to add two fields and display in text area?

Posted: Thu Feb 14, 2013 5:58 am
by Ryan Bloom

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

I call javascript upon value change of MP & AP


How to add two fields and display in text area?

Posted: Thu Feb 14, 2013 6:05 am
by maxkatz

Try to run the JS on button click.


How to add two fields and display in text area?

Posted: Thu Feb 14, 2013 6:14 am
by Ryan Bloom

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