How do I handle an HTML form from ruby?

L

Ludwigi Beethoven

--0-1675700967-1061405790=:59568
Content-Type: text/plain; charset=us-ascii
Content-Id:
Content-Disposition: inline

I am trying to learn how to manipulate HTML files with
ruby at the same time that I learn HTML. I created a
simple html file that contains among other things,
input text fields and some buttons. The problem now
is:

How do I tell ruby to run the html file?

Do I need to passit to a browser and if so, how?

How do I capture user's input?

I am including the html file, if anyone would like to
look at it.

Thank you

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<META name="GENERATOR" content="IBM WebSphere Homepage
Builder V5.0.1 for Windows">
<TITLE>Phone and Address Book</TITLE>
</HEAD>
<BODY bgcolor="#ccffff" text="#ff0000" link="#cc6666"
vlink="#cc9999" alink="#ffffff"
background="blue_p1b.gif">
<P align="center"><BR>
<B><FONT size="+4">Ruby</FONT></B></P>
<CENTER>
<FORM><FONT size="+2"><U><I><B>Telephone and Address
Book</B></I></U></FONT></FORM>
</CENTER>
<FORM>First Name: <INPUT size="20" type="text"
name="fn"><BR>
Last Name: <INPUT size="20" type="text" name="ln"><BR>
Address: <INPUT size="30" type="text"
name="addr"></FORM>
<P><B><FONT size="+4">Testing</FONT></B><BR>
</P>
<FORM><INPUT type="submit" name="sb" value="Submit
Your Form:"> <INPUT type="reset" name="rb"
value="Clear Form and Start Over"> </FORM>
<FORM><INPUT type="radio" name="rbg" value="This is a
radio button"></FORM>
<FORM><SELECT name="om">
<OPTION value="First Item" selected>one</OPTION>
<OPTION value="Second Item">two</OPTION>
</SELECT></FORM>
<FORM>
<FIELDSET><LEGEND>This is my title</LEGEND></FIELDSET>
</FORM>
<P><BR>
</P>
<FORM><INPUT type="checkbox" name="cb" value="Check it
out!"></FORM>
<P><BR></P>
<FORM><TEXTAREA rows="2" cols="6"
name="ta"></TEXTAREA></FORM>
</BODY>
</HTML>

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
--0-1675700967-1061405790=:59568
Content-Type: text/html; name="newpage1.html"
Content-Description: newpage1.html
Content-Disposition: inline; filename="newpage1.html"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META name="GENERATOR" content="IBM WebSphere Homepage Builder V5.0.1 for Windows">
<TITLE>Phone and Address Book</TITLE>
</HEAD>
<BODY bgcolor="#ccffff" text="#ff0000" link="#cc6666" vlink="#cc9999" alink="#ffffff" background="blue_p1b.gif">
<P align="center"><BR>
<B><FONT size="+4">Ruby</FONT></B></P>
<CENTER>
<FORM><FONT size="+2"><U><I><B>Telephone and Address Book</B></I></U></FONT></FORM>
</CENTER>
<FORM>First Name: <INPUT size="20" type="text" name="fn"><BR>
Last Name: <INPUT size="20" type="text" name="ln"><BR>
Address: <INPUT size="30" type="text" name="addr"></FORM>
<P><B><FONT size="+4">Testing</FONT></B><BR>
</P>
<FORM><INPUT type="submit" name="sb" value="Submit Your Form:"> <INPUT type="reset" name="rb" value="Clear Form and Start Over"> </FORM>
<FORM><INPUT type="radio" name="rbg" value="This is a radio button"></FORM>
<FORM><SELECT name="om">
<OPTION value="First Item">one</OPTION>
<OPTION value="Second Item" selected>two</OPTION>
</SELECT></FORM>
<FORM>
<FIELDSET><LEGEND>This is my title</LEGEND></FIELDSET>
</FORM>
<P><BR>
</P>
<FORM><INPUT type="checkbox" name="cb" value="Check it out!"></FORM>
<P><BR></P>
<FORM><TEXTAREA rows="2" cols="6" name="ta"></TEXTAREA></FORM>
</BODY>
</HTML>

--0-1675700967-1061405790=:59568--
 
B

Bermejo, Rodrigo

Hello,

It is not easy as it seems....
First at all you should have an HTTP server running ... do you have
one (apache.org) ?

regards.
 
P

Pit Capitain

No, I don't have an HTTP server running. I guess I
could install apache, but I thought that it was much
simpler.
All the examples make it look simple. Oh well!

Ludwigi, I'm not sure what you want exactly.

What do you mean by "manipulate"? Do you want to treat an HTML file
as text and do some processing on it, for example extracting the URL
of an image, or do you want to build a web application that processes
the user input in some way?

What do you mean by "run" the file? If you only want to look at it,
then you just ...

... open the file in your browser (usually via the File/Open menu).

This is where you start building a web application. If you press the
submit button in the browser, the browser sends the user's input via
the HTTP protocol somewhere (the target being mentioned in the <FORM>
tag). So you need a program that is able to process the data. I
suppose you want to use a Ruby program for that. If so, then you have
several choices, for example Webrick (look in the RAA).

HTH

Regards,
Pit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top