<input type="text" name="date1" id="dateField1" onchange="magicDate(''dateField1'');" onfocus="if (this.className != ''error'') this.select()" /> How could I generate above text filed using ruby? I am not sure how to give the options such as onchange, onfocus, id and so on? could some one please help. -- Posted via http://www.ruby-forum.com/.
Leendert Brouwer
2006-Aug-01 20:52 UTC
[Rails] Newbie: How to use text_field with Java Script
You can specify that behaviour in the options parameter of the text_field method in FormHelper. For example, you can do the following: <%= text_field :object, ''field'', :onchange => "your onchange javascript here", :onfocus => "your onfocus javascript here" %> HTH, Leendert On 8/1/06, Ruwan Budha <ruwanb@gmail.com> wrote:> > <input type="text" name="date1" id="dateField1" > onchange="magicDate(''dateField1'');" onfocus="if (this.className !> ''error'') this.select()" /> > > How could I generate above text filed using ruby? > > I am not sure how to give the options such as onchange, onfocus, id and > so on? > > could some one please help. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060801/199dfe37/attachment.html
Ruwan Budha
2006-Aug-01 21:13 UTC
[Rails] Re: Newbie: How to use text_field with Java Script
Leendert Brouwer wrote:> You can specify that behaviour in the options parameter of the > text_field > method in FormHelper. For example, you can do the following: > <%= text_field :object, ''field'', :onchange => "your onchange javascript > here", :onfocus => "your onfocus javascript here" %> > > HTH, > LeendertHi I did try it and it throws an error fallowing is my code <%= text_field ''reservation'', ''start_time'', :id => "dateField", :onchange =>"magicDate(''dateField'');", :onfocus="if (this.className != ''error'') this.select()" %> I believe the error occurs in onfocuse area as It might be getting confused with the input Could you someone pls help me to correct this? -- Posted via http://www.ruby-forum.com/.
Leendert Brouwer
2006-Aug-01 21:17 UTC
[Rails] Re: Newbie: How to use text_field with Java Script
On 8/1/06, Ruwan Budha <ruwanb@gmail.com> wrote:> > Leendert Brouwer wrote: > > You can specify that behaviour in the options parameter of the > > text_field > > method in FormHelper. For example, you can do the following: > > <%= text_field :object, ''field'', :onchange => "your onchange javascript > > here", :onfocus => "your onfocus javascript here" %> > > > > HTH, > > Leendert > > Hi I did try it and it throws an error fallowing is my code > > <%= text_field ''reservation'', ''start_time'', :id => "dateField", > :onchange =>"magicDate(''dateField'');", :onfocus="if (this.className !> ''error'') this.select()" %> > > > I believe the error occurs in onfocuse area as It might be getting > confused with the inputWhat''s the error? Are you getting a rails error, or a javascript error? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060801/d374e8d9/attachment.html
Leendert Brouwer wrote:> On 8/1/06, Ruwan Budha <ruwanb@gmail.com> wrote: >> >> Hi I did try it and it throws an error fallowing is my code >> >> <%= text_field ''reservation'', ''start_time'', :id => "dateField", >> :onchange =>"magicDate(''dateField'');", :onfocus="if (this.className !>> ''error'') this.select()" %> >> >> >> I believe the error occurs in onfocuse area as It might be getting >> confused with the input > > > What''s the error? Are you getting a rails error, or a javascript error?I am getting a rails error on this area :onfocus="if (this.className !>> ''error'') this.select()" its pointing the error on :onfocus=" <<<< on the quote symbol. Any ideas? -- Posted via http://www.ruby-forum.com/.
Daniel N
2006-Aug-02 01:39 UTC
[Rails] Re: Re: Newbie: How to use text_field with Java Script
On 8/2/06, woow <ruwanb@gmail.com> wrote:> > Leendert Brouwer wrote: > > On 8/1/06, Ruwan Budha <ruwanb@gmail.com> wrote: > >> > >> Hi I did try it and it throws an error fallowing is my code > >> > >> <%= text_field ''reservation'', ''start_time'', :id => "dateField", > >> :onchange =>"magicDate(''dateField'');", :onfocus="if (this.className !> >> ''error'') this.select()" %> > >> > >> > >> I believe the error occurs in onfocuse area as It might be getting > >> confused with the input > > > > > > What''s the error? Are you getting a rails error, or a javascript error? > > I am getting a rails error on this area :onfocus="if (this.className !> >> ''error'') this.select()" > > its pointing the error on :onfocus=" <<<< on the quote symbol. > > Any ideas? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >You have a typo. Should be :onfocus => " whereas you have only the -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060802/4dafd913/attachment.html
Kevin Olbrich
2006-Aug-02 01:42 UTC
[Rails] Re: Re: Newbie: How to use text_field with Java Script
On Wednesday, August 02, 2006, at 3:31 AM, woow wrote:>Leendert Brouwer wrote: >> On 8/1/06, Ruwan Budha <ruwanb@gmail.com> wrote: >>> >>> Hi I did try it and it throws an error fallowing is my code >>> >>> <%= text_field ''reservation'', ''start_time'', :id => "dateField", >>> :onchange =>"magicDate(''dateField'');", :onfocus="if (this.className !>>> ''error'') this.select()" %> >>> >>> >>> I believe the error occurs in onfocuse area as It might be getting >>> confused with the input >> >> >> What''s the error? Are you getting a rails error, or a javascript error? > >I am getting a rails error on this area :onfocus="if (this.className !>>> ''error'') this.select()" > >its pointing the error on :onfocus=" <<<< on the quote symbol. > >Any ideas? > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsTry this instead... <%= text_field :object, ''field'', {}, {:onchange => "your onchange javascript here", :onfocus => "your onfocus javascript here"} %> _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.