Re: Referencing WO fields in JavaScript
Re: Referencing WO fields in JavaScript
- Subject: Re: Referencing WO fields in JavaScript
- From: Seejo Pylappan <email@hidden>
- Date: Tue, 25 Oct 2005 09:48:18 -0400
Depends on what you want to do. If you have a single field which is
going to be processed by your javascript then you can explicitly name
the element and refer to it explicitly in the javascript.
If you are in a repetition where say you have a list to edit/delete
etc and then you want to process javascript to do the same function
as above, then declare a javascript var to hold the element id. Then
bind the id to a method in the component which just returns a simple
unique name with an incremental counter say 1employee, 2employee
etc.. On the buttons/link you have corresponding to each repetition
add the onClick() which sets the javascript var to the element id. So
when your javascript function calls aVar = document.getElementID
(currentIDToProcess).value you get the right value. This way you dont
have to worry about the names. The disadvantage being you have to
make sure that you have set the var to the required id before calling
the javascript function.
On Oct 25, 2005, at 9:29 AM, Arturo Perez wrote:
Is there anyway to get WO to generate the ID the way it generates
the NAME? I realize that sometimes you need to know the ID but
there are many cases (WORepetition) where you cannot make the name
unique without some help from WO.
I imagine people will say "bind to a method returning a string" but
how then does one consistently generate the same ID for same
element? Can the contextID be used?
-arturo
Seejo Pylappan wrote:
Add a attribute called id to the WOPasswordField in the inspector.
Give the id a unique name. Then from the javascript you can use:
aVar = document.getElementID('unique_name').value;
Hope this helps.
On Oct 25, 2005, at 9:10 AM, Stresing, Stephan wrote:
Hi,
we want to implement a low-level validation (and some security
things) of a WOPasswordField and here's my question:
how I can refer a dynamic WOPasswordField in an embedded
JavaScript routine?
Usually we'd do it in JavaScript like this: aVar = aField.value;
Can I refer to the WO name "3.7.2.2.1.5.3.11"?
Do I have to assign a "name" in the bindings of the
WOPasswordField? Obviously I'd prefer the WO notation (like
3.7.2.2.1.5.3.11)...
Snippet from generated HTML:
<input size="7" maxlength="6" type=password name="3.7.2.2.1.5.3.11">
Associated .wod:
MyField: WOPasswordField {
maxlength = 6;
size = 7;
value = myValue;
}
TIA!
Many regards,
Stephan.
Stephan Stresing
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden