Forums

How to set focus on a textbox

aldobz 27 Dec, 2015
Hi,
I have a very simple form wich contains only a textbox and a submit button.
I want load the form and set the focus to the textbox.

I tried the solution found here http://www.chronoengine.com/forums/posts/f2/t81505.html but it was unsuccessful.

In fact I used the Load JS in the On Load section and inserted this script


window.addEvent('domready', function() {
  $('tablet_focus').focus();
});


as suggested in the mentioned thread, where I replaced 'tablet_focus' with 'mailtodel', my Field ID.
Unfortunately, it don't works.
The JavaScript console brings this error: "Uncaught TypeError: window.addEvent is not a function"

What do I wrong? On the On Load section must the "Load JavaScript" be positioned before or after the "HTML Render Form"?
Your help would appreciated.
GreyHead 28 Dec, 2015
Hi aldobz,

The example you found is using the MooTools JavaScript library which Joomla! (and hence ChronoForms) dropped in Joomla! 3. Please try this jQuery version
jQuery(document).ready(function (jQ) {
  jQ('#mailtodel').focus();
});

The Load JavaScript action should be in the On Load event before the HTML (Render form) action.

Bob
This topic is locked and no more replies can be posted.