Newbie: How to use text_field with Java Script

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.

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

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 input

Could you someone pls help me to correct this?

Leendert Brouwer wrote:

On 8/1/06, Ruwan B. [email protected] 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?

On 8/1/06, Ruwan B. [email protected] 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?

On 8/2/06, woow [email protected]omain.invalid wrote:

Any ideas?


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

You have a typo. Should be :onfocus => " whereas you have only the =

On Wednesday, August 02, 2006, at 3:31 AM, woow wrote:

I believe the error occurs in onfocuse area as It might be getting
Any ideas?


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Try this instead…

<%= text_field :object, ‘field’, {}, {:onchange => “your onchange
javascript
here”, :onfocus => “your onfocus javascript here”} %>

_Kevin
www.sciwerks.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs