For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 3 replies, 3 voices, and was last updated 13 years ago by
support-michael.
-
AuthorPosts
-
TurgutGuneysuMemberKind of a newbie question:
I know how to access elements within the main app via document.getElementById() and use it to manipulate data.
However I have no idea on how to do it when in my program I receive a reply to a phoneui.submitForm() I have and the reply appears in the DATA parameter of the phoneui.postSubmitForm function.
I am able to apply data.match(regex filter) technique to scan for info I need. But I thought maybe there is simpler way to achieve it via getElementById applied to data somehow.
Any assistance is much appreciated.
TG
July 30, 2013 at 6:39 pm #341133
support-octavioMemberHi tguneysu,
>However I have no idea on how to do it when in my program I receive a reply to a phoneui.submitForm() I have and the reply appears in the DATA parameter of the phoneui.postSubmitForm function.
Are you receiving XML data or JSON data? Next examples can help you to learn how to process this kind of information:July 30, 2013 at 8:49 pm #341138
TurgutGuneysuMemberHi Octavio,
Thanks for the two references. I looked through them but I did not find anything where getElementById was applied to DATA received.
The form I post goes to a URL: company-z.com/s/…followed by the form fields.
In the form settings I select Form Result type:Data-HTML(AJAX)The reason I selected Data-HTML is that when I used WebPage UI it overwrote my sending screen.
DATA-HTML seems to not do that.The reply I receive is a HTML web page with the data fields embedded.
This result ends up in the DATA parameter of the PostSubmit function.
I have attached the resulting HTML file that I receive (Responsetext.txt).
I can also provide the actual URL and transaction details, but I do not want to post it here.
Sorry but I am very new to this and not quite familiar with all the ins and outs of phoneui , jquery, ajax etc. Just learning as I go along and seeking answers in the examples you guys provide.
Thanks for the patience.
TG
Attachments:
You must be logged in to view attached files.July 31, 2013 at 7:14 pm #341169
support-michaelKeymasterHi TG,
I realize your question is how to use the DOM javascript api. But let me propose that you give the jquery library a try. Please refer back to the xml example Octavio provided. It uses the jquery javascript DOM processing library and illustrates how to fetch an xml file and then search the XML document (DOM) for <message>some text</message>. The jquery api is already available to your app. MobiOne’s code generation includes jquery in your app.
In the following example, the line $(xmlDoc).find(‘message’).text() extracts the text for the single <message> tag.
function loadXMLFile(url){ phoneui.showActivityDialog("loading"); $.get(url, function(xmlDoc){ phoneui.hideActivityDialog(); var msg = $(xmlDoc).find('message').text(); //<-- access the element <message> and its content updateTextArea(msg); },"xml");In your example’s postSubmitXXX(data) function, the data parameter should be an HTML DOM. The Jquery lib can then be used to extract elements/attributes with ease.
Here is an untested equivalent using DOM javascript api instead of jquery api on the xml document returned by the jquery ‘get’ function. I added the id ‘msg1’ to example xml file to support the getElementById() query.
var msg = xmlDoc.getElementById('msg1').firstChild;I hope this is helpful.
-
AuthorPosts
