[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How can I get HTML's varibles in embeded ruby?

Zhan feng Wang

8/5/2007 7:39:00 AM

E.g.,I have following variables:
myInput, DataFile,TagFile in the following segment HTML codes.

<form name="myInput" action="deTap3-1.rhtml" method="POST">
<pre>
Select Asn1 File: <input name="DataFile" type="file" >
Select Asn1-bas File: <input name="TagFile" type="file">
<input type="hidden" name="action" value="submitted">
<input type="submit" name="Go" value="Go!">
<input type="reset" name="reset" value="Reset" OnClick="init()">
</pre>
</form>



If in PHP, I can easily get them by $p_DataFile, $p_TagFile etc, How can
I get the variables in embeded ruby?

Thanks
--
Posted via http://www.ruby-....

5 Answers

Shai Rosenfeld

8/5/2007 7:46:00 AM

0

Zhan feng Wang wrote:
> E.g.,I have following variables:
> myInput, DataFile,TagFile in the following segment HTML codes.
>
> <form name="myInput" action="deTap3-1.rhtml" method="POST">
> <pre>
> Select Asn1 File: <input name="DataFile" type="file" >
> Select Asn1-bas File: <input name="TagFile" type="file">
> <input type="hidden" name="action" value="submitted">
> <input type="submit" name="Go" value="Go!">
> <input type="reset" name="reset" value="Reset" OnClick="init()">
> </pre>
> </form>
>
>
>
> If in PHP, I can easily get them by $p_DataFile, $p_TagFile etc, How can
> I get the variables in embeded ruby?
>
> Thanks

<form name="myInput" action="deTap3-1.rhtml" method="POST">
<pre>
Select Asn1 File: <input name="DataFile" type="file" >
Select Asn1-bas File: <input name="TagFile" type="file">
<input type="hidden" name="action" value="submitted">
<input type="submit" name="Go" value="Go!">
<input type="reset" name="reset" value="Reset" OnClick="init()">
</pre>
</form>

just a note, but i don't think you want the 'form' action to go to the
file itself (the rhtml) .. it should go to the corresponding action that
calls that template.

i believe what you are seeking for is params[:DataFile],
params[:TagFile], etc.
(this may be good for the ruby on rails forum, rather than this plain
ruby forum) http://www.ruby-forum.c...

anyway hth.
happy sunday
--
Posted via http://www.ruby-....

John Joyce

8/5/2007 4:52:00 PM

0


On Aug 5, 2007, at 2:46 AM, Shai Rosenfeld wrote:

> Zhan feng Wang wrote:
>> E.g.,I have following variables:
>> myInput, DataFile,TagFile in the following segment HTML codes.
>>
>> <form name="myInput" action="deTap3-1.rhtml" method="POST">
>> <pre>
>> Select Asn1 File: <input name="DataFile" type="file" >
>> Select Asn1-bas File: <input name="TagFile" type="file">
>> <input type="hidden" name="action" value="submitted">
>> <input type="submit" name="Go" value="Go!">
>> <input type="reset" name="reset" value="Reset" OnClick="init()">
>> </pre>
>> </form>
>>
>>
>>
>> If in PHP, I can easily get them by $p_DataFile, $p_TagFile etc,
>> How can
>> I get the variables in embeded ruby?
>>
>> Thanks
>
> <form name="myInput" action="deTap3-1.rhtml" method="POST">
> <pre>
> Select Asn1 File: <input name="DataFile" type="file" >
> Select Asn1-bas File: <input name="TagFile" type="file">
> <input type="hidden" name="action" value="submitted">
> <input type="submit" name="Go" value="Go!">
> <input type="reset" name="reset" value="Reset" OnClick="init()">
> </pre>
> </form>
>
> just a note, but i don't think you want the 'form' action to go to the
> file itself (the rhtml) .. it should go to the corresponding action
> that
> calls that template.
>
> i believe what you are seeking for is params[:DataFile],
> params[:TagFile], etc.
> (this may be good for the ruby on rails forum, rather than this plain
> ruby forum) http://www.ruby-forum.c...
>
> anyway hth.
> happy sunday
> --
> Posted via http://www.ruby-....
>

OP didn't say Rails. Could very well be serving some kind of eruby.

Brett Simmers

8/5/2007 5:28:00 PM

0

Zhan feng Wang wrote:
> E.g.,I have following variables:
> myInput, DataFile,TagFile in the following segment HTML codes.
>
> <form name="myInput" action="deTap3-1.rhtml" method="POST">
> <pre>
> Select Asn1 File: <input name="DataFile" type="file" >
> Select Asn1-bas File: <input name="TagFile" type="file">
> <input type="hidden" name="action" value="submitted">
> <input type="submit" name="Go" value="Go!">
> <input type="reset" name="reset" value="Reset" OnClick="init()">
> </pre>
> </form>
>
>
>
> If in PHP, I can easily get them by $p_DataFile, $p_TagFile etc, How can
> I get the variables in embeded ruby?
>
> Thanks
>
You probably want to use the CGI class:
http://ruby-doc.org/core/classe...

That page has plenty of tutorials on it, but the basics are:

require 'cgi'
cgi = CGI.new
data_file = cgi['DataFile']

That'll give you the value of the DataFile text field.

-Brett

Zhan feng Wang

8/5/2007 11:29:00 PM

0

Brett Simmers wrote:

> You probably want to use the CGI class:
> http://ruby-doc.org/core/classe...
>
> That page has plenty of tutorials on it, but the basics are:
>
> require 'cgi'
> cgi = CGI.new
> data_file = cgi['DataFile']
>
> That'll give you the value of the DataFile text field.
>
> -Brett

Thanks a lot.
--
Posted via http://www.ruby-....

Lloyd Linklater

8/6/2007 12:59:00 PM

0

Zhan feng Wang wrote:
> E.g.,I have following variables:
> myInput, DataFile,TagFile in the following segment HTML codes.
>
> If in PHP, I can easily get them by $p_DataFile, $p_TagFile etc, How can
> I get the variables in embeded ruby?

Isn't hpricot (http://redhanded.hobix.com/inspect/hpri...) an
html parser package?
--
Posted via http://www.ruby-....