on 11-19-2009 5:15 PM
Hello,
I want to hide a field depending of the value of another field of the same line. the issue is that the line is from a nested table.
here is the code :
var nodList = xfa.resolveNodes("xfa.record.LISTE_POSTES_TRAVAIL.DATA[].LISTE_CARAC.DATA[].CARAC");
I want to get the value of "carac" field in table LISTE_CARAC_DATA.
So when I display this :
xfa.host.messageBox(""+nodList.item(this.parent.index).value);
I always see the values of the table LISTE_CARAC_DATA for the first line of LISTE_POSTES_TRAVAIL.
Could you help me ?
Thank you.
Hello,
I hope I don´t miss a reason why did you pick this kind of solution. Because I would like to propose you to use the relative addressing which is much easier in cases like yours (I hope).
If you have a structure:
table subform
row subform
field1
field2
and you need to hide (or anything else) field2 because there is some special value in field1, do it like this: (JavaScript)
- use event layout:ready (if it fits you), JS on client
- place the script into the row subform
if (this.field1.rawValue == "YOURVALUE")
this.field2.presence = "hidden";
(or you can go the other way round from child to the parent using field1.parent.field2 = navigation can be understood easily i think). Hope this helps, Otto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Everything works perfect, except if I want to modify a value for the next line (index + 1).
For example :
lineA
line A.1 field1
line A.2 field2
lineB
line B.1 field1
line B.2 field2
If field1 = 'X' set field2 as mandatory.
I tried something like that (Javascript) ::
if (this.rawValue == "X")
{
this.parent(this.index + 1).mandatory = "error";
}
but I get the error "this.parent is not a function". what is wrong ?
I just want the next field to be mandatory (it could be in any line), for example if i make the hierarchy more complex :
lineA
line A.1 field1
line A.2 field2
line A.3 field3
lineB
line B.1 field1
line B.2 field2
line B.3 field3
Let say line B.2 = "X", I would like to set line B.3 as mandatory.
If line A.1 = "X", then line A.2 is mandatory.
I just need a way to modify the line just after the one that is pointing by "this".
In my opinion your design is not right. From my point of view you have two types of rows:
- simple row (single criterium)
- combined row (criterium + mandatory detail)
that means you need only combined rows in your backend, only combined table in your form and on every row of the form you should hide the mandatory detail if that is not wanted. You do the opposite, you try to add something new/more and connect things together instead of hiding the unwanted (what would be like 1 script row manipulationg presence of the part of the row).
Otto
p.s.: I have written a blog because people cause themselves too many problems by a bad design/ form structure: /people/otto.gold/blog/2010/01/22/adobe-forms-use-your-imagination-first
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No Otto you won't make me rebuild my form
I think I just get what is wrong, the value of this.index is always 0, that explain why sometimes it works, and sometimes not.
Maybe I just need to put a counter in my table. I will do that if I don't find a javscript solution.
Anyway, thanks a lot Otto for your time and very helpful advice.
This is the code if it can help someone :
var nodTry = xfa.resolveNodes("$.parent.parent.parent.POSTE[*].multiple_resultat.RESULTAT_T1");
//The nodtry is complex because of all the subforms.
var selection = $.boundItem(xfa.event.newText);
if ( this.CARAC.rawValue == "LISTERIA" )
{
if ( selection == "YES" )
{
//COMPTEUR is the index that I created (I add a columns in my table and filled it in the ABAP program).
// I don't need to do "+1" because index started at 0 in adobe form.
nodTry.item(this.COMPTEUR.rawValue).mandatory = "error";
nodTry.item(this.COMPTEUR.rawValue).access = "open";
nodTry.item(this.COMPTEUR.rawValue).fillColor = "255,255,255";
}
else if ( selection != "YES" )
{
nodTry.item(this.COMPTEUR.rawValue).mandatory = "disabled";
nodTry.item(this.COMPTEUR.rawValue).access = "readOnly";
nodTry.item(this.COMPTEUR.rawValue).fillColor = "230,230,230";
nodTry.item(this.COMPTEUR.rawValue).rawValue = "";
}
}
Edited by: Louis-Arnaud Bouquin on Feb 9, 2010 11:39 AM
I don´t know how to easily "touch" the next row. Hope thats what you want to do? Only thing I can think of is to get the index of the line you want to do the access from. Next loop at the whole table (for every row!! performance problem!!) and count yourself the index of processed row and find yourself the "next one". But that is crazy. Maybe you can adapt your form structure or copy the values "somehwere" to ease this for you? I would refuse to do this +1 crazy thing:))
Otto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes this is what I whant to do, to be as clear as possible, this is the functionnal need :
My forms display a list of characteristics, for each work station :
WORK STATION A
CHARAC 1
CHARAC 2
CHARAC 3
....
WORK STATION B
CHARAC 1
CHARAC 2
CHARAC 3
For one special characteristic(let say if charac = "LISTERIA"), then if the value of this characteristic is "YES", the characteristic just below should be mandatory (to fill how many listeria has been detected).
But LISTERIA could be place anywhere in the form...
I wish I could refuse to do that but it does not seems to be an option
ok, ok, keep it on your field but use the parent "pointer" to access the other fields of this line instance. That should help you, Otto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Otto,
I think I am getting it, but I just miss something.
So I wrote something like that :
field1.parent.????.field1.mandatory = "error".
What can I wrote to replace the ????, because I would like to take the next line.
I tried field1.parent(this.index + 1)....
field1.parent[this.index + 1)...
But no success...
I don´t understand the question. There is always the same list of events available. You only pick the right one from the list. If you use only "Events with scripts" then you will see nothing one level up I guess. And I don´t understand why you cannot change your existing script (on the field) and you need to work with the field:)) But ...there´s always a way... use "parent" directive instead of only "this". Example: myfield.parent points to the mentioned level up (parent) subform.
Regards, Otto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
you need to move your script one level up. This will point to the line subform and no to the field.
Like this.myfield.rawValue instead of only this (field).rawValue. This way you can access the whole row (all fields).
Otto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.