RE: [PEAR] javascript:focus() on formelements

From: Date: Wed, 17 Dec 2003 16:00:25 +0000
Subject: RE: [PEAR] javascript:focus() on formelements
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9618@lists.php.net to get a copy of this message
> -----Original Message----- > From: Mike Carter [mailto:mikeatwork@ukonline.co.uk] > > > -----Original Message----- > > From: Birgir Stefansson [mailto:bs@hi.is] > > > > I know this is not a PEAR og HTML_QuickForm question as such > > but rather > > a javascript question but here goes, in case anyone knew a way to do > > this. > > I wish to do the same thing. My JavaScript knowledge is > rubbish. I would imagine getting an array of child elements > for the form node, then simply setting the [0] index of the > array to have initial focus. > > Would that work? I think the thing is you have to trigger the focus() somehow or have it triggered same goes for any other javascript functions, I would think ? $form = new HTML_QuickForm('testForm'); $form->addElement('text','testField','Test:',array('onMouseOver' => 'document.testForm.testField.focus();')); $form->display(); Here the user has to move the mouse over the textfield which is not what I want. Here's some javascript example. http://www.js-examples.com/example/?ex=127&mode=1 Another way to focus would to put in a <body onLoad="document.testForm.testField.focus();"> I want to try and keep the focus() inside or as close as possible to the form code as possible. Any ideas ? Birgir

« previous php.pear.general (#9618) next »