Thank you for your quick response.
I believe inputs[i].onkeypress = function(e) {
e = e || window.event;
...
}
is similar to
inputs[i].onkeypress = "javascript: return handleEnter(this, event)";
-- this is what I tried and it didn't work either.
Basically what I need to do is, set handleEnter() for all text fields
at run time to avoid hard coding onkeypress = "javascript: return
handleEnter(this, event);" for textboxes across pages and handle Enter
key event to submit the page for those text boxes.
Am I missing anything?
Thanks,
Kcnu
On Oct 13, 5:22 pm, kangax <[EMAIL PROTECTED]> wrote:
> On Oct 13, 4:52 pm, kcnu <[EMAIL PROTECTED]> wrote:
>
> > Hello All,
>
> > I need some help to add 'onkeypress' event attribute to HTML <INPUT>
> > elements.
>
> There's a bit easier solution:
>
> $$('input[type=text]').invoke('observe', 'keypress', function(e) {
> if (!test()) e.stop();
>
> });
>
> > Below code works fine in Firefox, but not at all in IE 7.
>
> > var inputs = document.getElementsByTagName("input");
> > for (i = 0; i < inputs.length; i++ )
> > {
> > if(inputs[i].type == 'text'') {
> > alert('name is-->>>'+inputs[i].name);
> > inputs[i].setAttribute("onkeypress",
> > "javascript:return test()");
> > }
> > }
>
> > Tried writeAttribute() in prototype 1.6.0.2 too but no use in IE 7.
>
> But if you don't feel like using `observe`, just assign a function
> reference, rather than setting attribute:
>
> inputs[i].onkeypress = function(e) {
> e = e || window.event;
> ...
>
> }
>
> > Thanks,
> > Kcnu
>
> --
> kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---