maxtillberg
Posts: 0
Joined: Tue Nov 27, 2012 3:40 pm

copy data

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

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

copy data

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

maxtillberg
Posts: 0
Joined: Tue Nov 27, 2012 3:40 pm

copy data

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

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

copy data

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...

maxtillberg
Posts: 0
Joined: Tue Nov 27, 2012 3:40 pm

copy data

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

/Max

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

copy data

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

maxtillberg
Posts: 0
Joined: Tue Nov 27, 2012 3:40 pm

copy data

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

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

copy data

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

maxtillberg
Posts: 0
Joined: Tue Nov 27, 2012 3:40 pm

copy data

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

Sincerely,
Max

Return to “Issues”