How to Post html form data?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
colourpixels
Posts: 83
Joined: Mon Oct 31, 2011 5:28 am

How to Post html form data?

Post by colourpixels » Mon Dec 12, 2011 6:56 am

Hi All,
New to live code and wonder how I would go about sending post data to a web page? I have a webview and would like to have a search text box using live code controls outside of the website that loads a google search results in the the webview (using a google custom search engine on my web page).

I'm guessing I need to use:
post tData to url "www myurl com/search"

For say an html form:

Code: Select all

<form  action="www myurl com/search" id="cse-search-box">
    <input type="hidden" name="cx" value="011441403124570402395:0xkr9rxifjs" />
    <input type="hidden" name="cof" value="FORID:9" />
    <input type="hidden" name="ie" value="UTF-8" />
    <input type="text" name="q" size="23"  />
     </form>
What code would I need to generate for my tdata variable, do I need to url encode tdata ( e.g. URLEncode(data) )

Many thanks, hope someone can answer as I imagine this is something newbies run into fairly often.

Cheers
Dale

colourpixels
Posts: 83
Joined: Mon Oct 31, 2011 5:28 am

Re: How to Post html form data?

Post by colourpixels » Tue Dec 13, 2011 1:46 am

in response to my own question, a google custom search can take URL parameters, so I went with the following:

Code: Select all

global gBrowserA,gInputA

on touchEnd pId
   mobGUIUntouch the long id of me
   put iphoneControlGet(gInputA["searchInput"], "text")  into searchQuery
   iphoneControlSet gBrowserA["BrowserFIT"], "url", "somewhere do t net slash search? "q="&searchQuery&"&cx=011441403124570402395:0xkr9rxifjs&cof=FORID:9"
   
end touchEnd

Post Reply