Question

My question might seem trivial but I can't find resources about selecting elements that are descendant of a given element.

I have a form in which I want all fields (they should be all the inputs and selects that are child of the form tag, except buttons) to submit the form when ENTER key is pressed. Actually I require to call a custom Javascript method to submit the form, instead of merely submitting it the plain old way.

This because I need to raise a different Stripes ActionBean event depending on the button being hit (or in the case of enter key I know what event to fire a priori).

I can apply a custom CSS class to all fields (booooooooooooring) and I can select all form fields in a page with $$('input[type!=button], select').

How to constrain the selection to elements that descend from a given form tags (which has an ID?). The selection will be used to handle the keyup event

Was it helpful?

Solution

$$('input[type!=button],select', '#formid')

* selects all elements.

OTHER TIPS

Something along the lines of

$$('#formId input[type!=button],#formId select')

Haven't been using prototype but i assume most CSS selectors work

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top