rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* Checkbox selection trouble in request.params
@ 2012-06-13  7:55 Randy M
  2012-06-15 15:58 ` Joshua Ballanco
  0 siblings, 1 reply; 5+ messages in thread
From: Randy M @ 2012-06-13  7:55 UTC (permalink / raw)
  To: Rack Development

Hello everyone.

I'm using rack (1.4.1), but it seems cannot receive
checkbox selection value..

 http://localhost/hello.cgi?foo=1&foo=3
 Hello, Rack
 {"foo"=>"3"}

Code below.

 #!ruby
 require "rack"
 class HelloRack
  def call(env)
    req = Rack::Request.new(env)
    return [200, {"Content-Type" => "text/plain"},
             "Hello, Rack\n" +  req.params.inspect  ]
  end
 end
 Rack::Handler::CGI.run HelloRack.new

Could anyone tell me idea?


----------
Randy Michaels
randy_michaels@aol.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Checkbox selection trouble in request.params
  2012-06-13  7:55 Checkbox selection trouble in request.params Randy M
@ 2012-06-15 15:58 ` Joshua Ballanco
  2012-06-15 17:15   ` Randy M
  0 siblings, 1 reply; 5+ messages in thread
From: Joshua Ballanco @ 2012-06-15 15:58 UTC (permalink / raw)
  To: rack-devel

[-- Attachment #1: Type: text/plain, Size: 838 bytes --]

You've only passed one parameter. The first "foo=1" sets the foo parameter to 1. The second "foo=3" re-assigns foo to 3. If you want two parameters to be passed to your app, you need to define two separate parameters.

On Wednesday, June 13, 2012 at 10:55 AM, Randy M wrote:

> Hello everyone.
> 
> I'm using rack (1.4.1), but it seems cannot receive
> checkbox selection value..
> 
> http://localhost/hello.cgi?foo=1&foo=3
> Hello, Rack
> {"foo"=>"3"}
> 
> Code below.
> 
> #!ruby
> require "rack"
> class HelloRack
> def call(env)
> req = Rack::Request.new(env)
> return [200, {"Content-Type" => "text/plain"},
> "Hello, Rack\n" + req.params.inspect ]
> end
> end
> Rack::Handler::CGI.run HelloRack.new
> 
> Could anyone tell me idea?
> 
> 
> ----------
> Randy Michaels
> randy_michaels@aol.com (mailto:randy_michaels@aol.com)
> 
> 



[-- Attachment #2: Type: text/html, Size: 1768 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Checkbox selection trouble in request.params
  2012-06-15 17:15   ` Randy M
@ 2012-06-15 17:11     ` Silviu Rusu
  2012-06-16  8:13       ` Randy M
  0 siblings, 1 reply; 5+ messages in thread
From: Silviu Rusu @ 2012-06-15 17:11 UTC (permalink / raw)
  To: rack-devel


correct way to use this:

<input type="checkbox" name="foo[]" value="1"> Item 1
<input type="checkbox" name="foo[]" value="2"> Item 2

note []  after foo


On Jun 15, 2012, at 8:15 PM, Randy M wrote:

> Well, but these HTML checkbox generates that query_string..
> 
> <input type="checkbox" name="foo" value="1"> Item 1
> <input type="checkbox" name="foo" value="2"> Item 2
> 
> at Rack, we cannot use these type form field?
> 
> 
> On 6月16日, 午前12:58, Joshua Ballanco <jball...@gmail.com> wrote:
>> You've only passed one parameter. The first "foo=1" sets the foo parameter to 1. The second "foo=3" re-assigns foo to 3. If you want two parameters to be passed to your app, you need to define two separate parameters.
>> 
>> On Wednesday, June 13, 2012 at 10:55 AM, Randy M wrote:
>>> Hello everyone.
>> 
>>> I'm using rack (1.4.1), but it seems cannot receive
>>> checkbox selection value..
>> 
>>> http://localhost/hello.cgi?foo=1&foo=3
>>> Hello, Rack
>>> {"foo"=>"3"}
>> 
>>> Code below.
>> 
>>> #!ruby
>>> require "rack"
>>> class HelloRack
>>> def call(env)
>>> req = Rack::Request.new(env)
>>> return [200, {"Content-Type" => "text/plain"},
>>> "Hello, Rack\n" + req.params.inspect ]
>>> end
>>> end
>>> Rack::Handler::CGI.run HelloRack.new
>> 
>>> Could anyone tell me idea?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Checkbox selection trouble in request.params
  2012-06-15 15:58 ` Joshua Ballanco
@ 2012-06-15 17:15   ` Randy M
  2012-06-15 17:11     ` Silviu Rusu
  0 siblings, 1 reply; 5+ messages in thread
From: Randy M @ 2012-06-15 17:15 UTC (permalink / raw)
  To: Rack Development

Well, but these HTML checkbox generates that query_string..

 <input type="checkbox" name="foo" value="1"> Item 1
 <input type="checkbox" name="foo" value="2"> Item 2

at Rack, we cannot use these type form field?


On 6月16日, 午前12:58, Joshua Ballanco <jball...@gmail.com> wrote:
> You've only passed one parameter. The first "foo=1" sets the foo parameter to 1. The second "foo=3" re-assigns foo to 3. If you want two parameters to be passed to your app, you need to define two separate parameters.
>
> On Wednesday, June 13, 2012 at 10:55 AM, Randy M wrote:
> > Hello everyone.
>
> > I'm using rack (1.4.1), but it seems cannot receive
> > checkbox selection value..
>
> >http://localhost/hello.cgi?foo=1&foo=3
> > Hello, Rack
> > {"foo"=>"3"}
>
> > Code below.
>
> > #!ruby
> > require "rack"
> > class HelloRack
> > def call(env)
> > req = Rack::Request.new(env)
> > return [200, {"Content-Type" => "text/plain"},
> > "Hello, Rack\n" + req.params.inspect ]
> > end
> > end
> > Rack::Handler::CGI.run HelloRack.new
>
> > Could anyone tell me idea?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Checkbox selection trouble in request.params
  2012-06-15 17:11     ` Silviu Rusu
@ 2012-06-16  8:13       ` Randy M
  0 siblings, 0 replies; 5+ messages in thread
From: Randy M @ 2012-06-16  8:13 UTC (permalink / raw)
  To: Rack Development

That's my answer.. thankyou!

> correct way to use this:
>
> <input type="checkbox" name="foo[]" value="1"> Item 1
> <input type="checkbox" name="foo[]" value="2"> Item 2
>
> note []  after foo
>
> > Well, but these HTML checkbox generates that query_string..
>
> > <input type="checkbox" name="foo" value="1"> Item 1
> > <input type="checkbox" name="foo" value="2"> Item 2
>
> > at Rack, we cannot use these type form field?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-06-16  8:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-13  7:55 Checkbox selection trouble in request.params Randy M
2012-06-15 15:58 ` Joshua Ballanco
2012-06-15 17:15   ` Randy M
2012-06-15 17:11     ` Silviu Rusu
2012-06-16  8:13       ` Randy M

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).