Placing text into browser input box

I have a simple html submit form with a text input box.  How do I place text into it on the browser from Delphi?

Not using (TWebBrowser)
Grant FullenAsked:
Who is Participating?
MerijnBSr. Software EngineerCommented:
in that case, make it a simple asp or php page, so you can give the contents of the box in the url itself, will save you lots of trouble :)
What are you using?  Delphi.NET, CGI, etc?

Grant FullenAuthor Commented:
Just regular delphi.

I have Internet Explorer open with a simple html submit form with one edit and a submit button.  I want to place text into that edit from delphi.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

MerijnBSr. Software EngineerCommented:
sounds like you also host the html page, is this true?
Grant FullenAuthor Commented:
Yup.  It's mine.
I'm having trouble understanding what you ultimately want to do.  I understand that you have a web page and you want to put values on it from a Delphi application, but is this to generate a report, or is it going to be an interactive application?

If you are making an application that will process html form data, you may want to create your own web-server application: one that receives the input and generates the output itself.  For this you could use the wonderful ICS TWSocket components from Francois Piette, in particular the HttpSrv (Http Server) component.  You can find these components at <>.  TWSocket has an excellent support mailing list with many experts that can answer any questions and offer help or sample code.

If you just want to generate an html page wih static text (one that does not need to be posted back for processing, like a report), then you can just create a Delphi command-line application that will "print" as its output the html page.  This is basically what CGI applications are.

If you have Delphi 2006, you could use Delphi.NET to create an ASP.NET page which will be a lot simpler:  You can create a web page that has delphi code running "behind-the-scenes", that can process input and generate output, with a simple html template.  This is the easiest approach.

If you don't have Delphi.NET, you could also make a COM component for use in a Classic ASP page.  The COM component would do the necessary processing of your page, and then the asp page will contain html along with some script to instantiate the component and process the input and output.

You could also use WebSnap (a Delphi technology for web components) that will work pretty much as the COM approach a mentioned above.

If you have the latest Delphi For PHP, then its even easier! With that you can write Delphi code that will process a web page, generating output from your code. <>.

You can find some information about the technologies I mentioned above, along with some tutorials, on this site: <>.

It all depends on which version of Delphi you have, and what you want or need to do.  Telling us "I want to put text in the Edit from Delphi" does not offer much information, because we still don't know if you need to interact with the user in other ways or just generate a static html page.

Grant FullenAuthor Commented:
MerijnB, it's a file text box for posting a file to a php script.  How would I place it in the url?
      I'm curious to know why you accepted a solution when it seems that it didn't answer your question?  I'm just wondering since the asnwer you accepted does not tell you how to set the text from Delphi into the TextBox (which is your original question), nor explains how to put the value into the URL or how to use it (as it proposed).

If you are using Delphi to generate an HTML page, you can inject the value into the textbox like this:

     StrTextValue := 'Hello world!';
     HtmlOutput := HtmlOutput + '<input type="text" name="myTextBox" value="' + StrTextValue + '">' + #13#10;

Where HtmlOutput reprecents the buffer contianing the html output you are generating, and StrTextValue represents the value you want to set in the TextBox.

If you are using Delphi For PHP then you can do it like this:

From code:

// $myTextBox represents the name of the TextBox control
$myTextBox->Text = "Hello world!";

Or from templates:

    <form ...>
        <input type="text" name="myTextBox" value="{ $TextValue }">

Here's some information on how to do a simple Delphi For PHP page:

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.