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

Z

Zhan feng Wang

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
 
S

Shai Rosenfeld

Zhan said:
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.com/forum/3

anyway hth.
happy sunday
 
J

John Joyce

Zhan said:
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.com/forum/3

anyway hth.
happy sunday

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

Brett Simmers

Zhan said:
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/classes/CGI.html

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
 

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top