Page 1 of 1

copy data

Posted: Tue Nov 27, 2012 3:40 pm
by maxtillberg

I would like to grab information from a select menu, make some calculation based on this and present the result in a label. For some reason I failed totaly and wonder if someone could provide some help?

Sincerely
Max


copy data

Posted: Tue Nov 27, 2012 4:03 pm
by maxkatz

Please tell us what you tried (code, etc) and what didn't work.


copy data

Posted: Tue Nov 27, 2012 8:50 pm
by maxtillberg

I tried something like this
function(calculatekanaldim);

and a function calculatekanaldim containing

var input = Tiggr('kanaldiameter');
input = input/2;
Tiggr('tryckfall').text('input')

where kanaldiameter is the name of the select and tryckfall is the label.

Sincerely,
Max


copy data

Posted: Tue Nov 27, 2012 9:19 pm
by maxkatz

Tiggzi(id) gives you a jQuery Mobile component, you then need to either use .text() or .val(), depending on the component to get the actual value.

http://docs.tiggzi.com/javascript-api...


copy data

Posted: Fri Nov 30, 2012 12:50 pm
by maxtillberg

I tried something very simple like
Tiggzi('tryckfall').text("hello")
but the text is not changed, any ideas?

/Max


copy data

Posted: Fri Nov 30, 2012 1:53 pm
by Kateryna Grynko

Hello! Try this code:
codeTiggzi('tryckfall').val("hello")/code


copy data

Posted: Sat Dec 01, 2012 5:07 pm
by maxtillberg

Thanks, That worked fine but when I run the code within a javascript nothing happens. I try to run the script by
calculate();

Any ideas?

/Max


copy data

Posted: Sat Dec 01, 2012 5:17 pm
by maxkatz

I don't understand what didn't work... you have to debug your JavaScript. Put console.log(..) statements and see what you get. Are you selecting the right jQuery Element in the DOM?

To read a value from a select menu, you would do this:

var value = Tiggzi('id').val();

where 'id' is the name of the select menu. To assign that value to a label:

Tiggzi('label_id').text(value);


copy data

Posted: Mon Dec 03, 2012 12:26 pm
by maxtillberg

For some reason this does not work, any ideas.
Image
Image

Sincerely,
Max