# How to use javascript in rhtml

**URL:** <https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/118314>\
**Category:** Ruby\
**Created:** [October 25, 2007, 4:22pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/118314 "2007-10-25T16:22:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 25, 2007, 4:22pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/118314/1 "2007-10-25T16:22:58Z")

</div>

hello,

I needed to know a javascript function which I can use for focusing my  
cursor on the first text field of a given page.

That is as soon as I load a page, my cursor should start blinking in the  
first text field

Regards

Advait

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 25, 2007, 6:13pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/118314/2 "2007-10-25T18:13:26Z")

</div>

Advait B. wrote:

> hello,
> 
> I needed to know a javascript function which I can use for focusing my  
> cursor on the first text field of a given page.
> 
> That is as soon as I load a page, my cursor should start blinking in the  
> first text field
> 
> Regards
> 
> Advait

If you are loading the prototype javascript library, you add the  
following to your view (after the form definition):

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 26, 2007, 2:37pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/118314/3 "2007-10-26T14:37:04Z")

</div>

Scott Patten wrote:

> Advait B. wrote:
> 
> > hello,
> > 
> > I needed to know a javascript function which I can use for focusing my  
> > cursor on the first text field of a given page.
> > 
> > That is as soon as I load a page, my cursor should start blinking in the  
> > first text field
> > 
> > Regards
> > 
> > Advait
> 
> If you are loading the prototype javascript library, you add the  
> following to your view (after the form definition):

Thank you for looking into by problem, however the problem still  
persists…I am actually new to this and trying to get a foot  
hold…and didnt get a clear picture of what you ment when you  
said  
" If you are loading the prototype javascript library, you add the  
following to your view (after the form definition) ".

could you please be more clear to me, so that I could you your help to a  
much efficient use

Thank you

Advait

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 26, 2007, 5:34pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/118314/4 "2007-10-26T17:34:55Z")

</div>

Advait B. wrote:

> hello,
> 
> I needed to know a javascript function which I can use for focusing my  
> cursor on the first text field of a given page.
> 
> That is as soon as I load a page, my cursor should start blinking in the  
> first text field

Learn javascript, then write the code to do that. Or, hire someone to  
write the js for you.

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 26, 2007, 6:27pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/118314/5 "2007-10-26T18:27:46Z")

</div>

7stud – wrote:

> Advait B. wrote:
> 
> > hello,
> > 
> > I needed to know a javascript function which I can use for focusing my  
> > cursor on the first text field of a given page.
> > 
> > That is as soon as I load a page, my cursor should start blinking in the  
> > first text field
> 
> Learn javascript, then write the code to do that. Or, hire someone to  
> write the js for you.

Thanks For the suggestion , But I better learn…thank you once  
again

Regards

Advait
