make form action as simple HTML

I have simple HTML.

<form action= method=get>
<input type=text name=q>
<input type=submit>

How to make xojo web app to same as above?
I make as below, but cause error in NextSocket.SetFormData(d) as Exception as NilObjectException.

Sub Action()
  Var d As New Dictionary
  d.Value("q") = TextField1.text
End Sub

That would seem to suggest that NextSocket has not been created yet. What does your code look like to instantiate that object?

NextSocket = new URLConnection

Thank you Anthony!

I already added property “NextSocket” as HTTPSocket at “Webpage1”.
So, I modify as :

Var d As New Dictionary d.Value("q") = TextField1.text NextSocket = new URLConnection NextSocket.SetFormData(d) NextSocket.Post("")

but, Type mismatch error at line of “NextSocket = new URLConnection”
So, I delete property “NextSocket” from “Webpage1”, but error “This item does not exist” at line of"NextSocket = new URLConnection"

any help?

If you’re using HTTPSocket, then the instantiation line should be this:

NextSocket = new HTTPSocket

Anthony, Thank you again!

I restore property “NextSocket” as “HTTPSocket” from "Webpage1.
and I change as below at Button1:

Var d As New Dictionary d.Value("q") = TextField1.text NextSocket = new HTTPSocket NextSocket.SetFormData(d) NextSocket.Post("")

All errors is clear.
But, when I push Button1, cause nothing.

One more breath!

If you’re trying to retrieve and parse search results, then you’ll have to implement the PageReceived event.

Add a method like this:

Private Sub handler_PageReceived(sender as HTTPSocket, url as String, httpStatue as Integer, headers as InternetHeaders, content as String) '// Do something with content here. End Sub

Then, after the line to instantiate NextSocket:

AddHandler NextSocket.PageReceived, AddressOf handler_PageReceived

Hi! Thank you Anthony!

I don’t want parsing results, I just want a page move to an arbitrary URL with POST or GET form data.
In my last experiment, pressing Button1 did not turn the web page.
What can I do for such a purpose?

I don’t understand what you mean by “turn the web page”. If you just want to submit data, then what are you expecting to happen in Xojo?


I want to below flow:

  1. I deploy xojo web application to hosting server as “index.cgi”.
  2. I open “http:///index.cgi” by web browser.
  3. I get xojo web application UI with TextField1 and Button1.
  4. I input to TextFIeld1 as “intel” and push Button1.
  5. Web browser shows “” with search keyword as “intel”. Xojo web application has gone. Web browser no make new tab or window.

“Turn the page” means 5.

I think this is what you’re after.

I believe he wants to set the .value of an input element in an external website. I’m a bit lost :slight_smile:

Thank you Anthnony!

I write as:


It is work without form value. But,

Var d As New Dictionary d.Value("q") = TextField1.text Me.ShowURL.SetFormData(d) Me.ShowURL("")

Xojo sais:
Not enough arguments: got 0, expected at least 1.

Hello Hector!

I believe he wants to set the .value of an input element in an external website. I’m a bit lost :slight_smile:

Yes. I want to set the value of an input element.

That won’t work. You’ll need to use URL parameters as the HTTPSocket isn’t going to help with what you want to do. For Google, you can read up on these here.

I found it.
I will try this.

I make code as below:

dim NextSocket as new HTTPSocket
dim d as new Dictionary
d.value(“q”) = TextField1.text

Var result As String
result = NextSocket.Get(“”, 30)
result = DefineEncoding(result, Encodings.UTF8)


It is run without NilObjectException.
Certainly the HTTPSocket + SetFormData didn’t help for Google.
I make URL praramater instead SetFormData as :

dim NextSocket as new HTTPSocket
var d as string
var URLstring as string
URLString = ""+ TextField1.text
Var resultdata1 As String
resultdata1 = NextSocket.Get(URLString, 30)

This is not what I want to do.
We do not want to put the results of the HTTP request to resultdata1 variable, but want to display a URLString to the web browser.

How can we make this happen?

I find simple solution as:


Thank you.