- This topic has 20 replies, 4 voices, and was last updated 10 years, 9 months ago by jonathannew.
-
AuthorPosts
-
Code_AMember@jonathannew wrote:
Hi Code A, I tried to replace with a text label as you suggested but i am not able to display my calculated results to this text label.
As Michael shows in the example above, make sure you are using the .text() property to set the label text instead of .val().
jonathannewMemberDear support Michael, I would like to clarify there was an error in your code and it has to be written exactly as below.
$('[id$=displayTxt]').text("7")
My second question is that if I have a page2 (name:page2.mobi) which contains another dynamic text label (name: displayTxt2), I do not need to reference it like the below. I just need to have unique names for each text label in all my mobi pages to control them?
$('#m1-page2-displayTxt2').text("other");
Code_AMemberYou should be able to reference it either way. Is your code not working? If you are using the id method then you should be using unique names.
jonathannewMemberDear Code A, yes, when I copied Michael’s syntax exactly, the code did not work. So I browse through the forum and found some coding related to text labels. It seems to me that double quotation marks and a close bracket are needed. After adding those 2, the code worked. In my learning of M1, I benefited much from the info on this forum and thought to correct this “if it was a mistake” so that others may benefit in the same way I did. But based on your reply, it seems Michael’s coding is correct and should work…
To confirm the answer to my 2nd question, as long as I use this ID method, I need not reference the mobi filename in the code even if I may have multiple mobi files in 1 app ? I need to clarify further that I am putting this javascript code in the main_custom.js file, meaning pressing the number button in my calculator project will call up a javascript function which ultimately will do some calculations writing results to the text label.
Code_AMember1. The text value should have quotations around it as you have indicated.
2. As long as you use unique names for your widgets the id method will work.
jonathannewMemberThanks for the clarifications!
-
AuthorPosts