- This topic has 3 replies, 2 voices, and was last updated 14 years, 1 month ago by wayne.
-
AuthorPosts
-
vacounMemberHello everyone.I have a following problem.I am trying to input some text with textfield and then use it in javascript.I have used similar statement in normal javascript editor and it worked ok.For some reason,this method doesn’t work in mobione generated HTML.I am probably missing something,but unfortunately,there is not much documentation for Mobione.Here is the part of my HTML code
<input id=”m1-Init-textField1″ class=”m1-textfield m1-font-Helvetica-3 m1-textfield-custom”
value=”” type=”text” name=”textField1″/>
<input id=”m1-Init-textField3″ class=”m1-textfield m1-font-Helvetica-3 m1-textfield-custom”
value=”” type=”text” name=”textField3″/>
<input id=”m1-Init-textField4″ class=”m1-textfield m1-font-Helvetica-3 m1-textfield-custom”
value=”” type=”text” name=”textField4″/>
<input id=”m1-Init-textField2″ class=”m1-textfield m1-font-Helvetica-3 m1-textfield-custom”
value=”” type=”text” name=”textField2″/><div id=”m1-Init-next1″
class=”m1-next-button m1-font-Helvetica-4 m1-transition-default m1-shadow-1 m1-hyperlink m1-button”
name=”next1″ onclick=”createDbase(textfield1,textField2,textField3,textField4)” href=”#m1-Serve”>Submit</div>The name of HTML document is init.htm,function createDbase is defined in init_custom.htm which I included in document.
When I try to test this,the debbuger console shows message “can’t find variable:textfield1”.
I also tried to get the submited data through “document.getElementById”,but i did not succed as well.
Any help would be appreciated
wayneModerator…I also tried to get the submited data through “document.getElementById”,but i did not succed as well.
getElementById(“yourId”) should definitely work but you will need to use the ID in the code since it gets slightly mangled during the code-generation phase. The ID mangling is the result of adding a prefix to each ID to ensure that it is unique across your application, i.e., when merging in linked designs it is highly likely that some designs will have controls with the same ids which would cause problems during layout.
Resolution: open the HTML source file and look up the mangled ID name of the <input> who’s value you want. Then use that ID as the parameter in getElementById(yourId).
Wayne
Genuitec Mobile Team
vacounMemberThank you,Wayne,for a quick answer,I really appreciate it.Unfortunately,I am still not able to use the textfield data in JS file.When the program gets to the line with getElementByID() mobione test center displays this error:
“TypeError: Result of expression ‘document.getelementbyid’ [undefined] is not a function.”
The statement I use is as follows:
“var pr1=document.getelementbyid(‘m1-Init-textField1’)”
I am sure,that I am using the right ”mangled” ID.I have also tried similar methods like getElementsByName(),but always with the same result.My Javascript knowledge is limited,but when I use this statement in some Javascript editor it works without a problem.BTW I would be really grateful for some documentation for Mobione,because I think this tool is great and I would like to know more about it
Regards Jan
wayneModeratorThe statement I use is as follows: "var pr1=document.getelementbyid('m1-Init-textField1')"
JavaScript is case sensitive and the function literally must be spelled getElementById(‘m1-Init-textField1’)
Wayne
Genuitec Mobile Team -
AuthorPosts