I'm trying to display a value given a code entered by a user.
Since I work with InfoPath 2007, it just support xPath 1.x, so to create a simple if-statement I constructed a rule like this:
substring(Value1, 1, (. = Code) * string-length(Value1)) // Value1 and Code is from a secondary datasource this secondary datasource is an XML "codelist" which should help me map a zipcode to a cityname. Code = 1234 => Value1 = New York
This xPath-expression, rule, on one field do set a value in another field. In the first field a user types a zip-code, which should end up as a cityname in the second field.
My codelist would then be so that Code[1] = 1234, Value1[1] = New York; Code[2] = 4321, Value1[2] = Miami;
The xPath expression above does find the code value, i.e. if I type "1234" in the first field the second field displays "New York". I guess it is able to find out that there actually is a code-node containing "1234". If I type "4321" I would like the second field to display "Miami", but i still displays "New York". I guess it is able to find out that there is a Code-node containing "4321", but it wrights the wrong Value1-node. (If I type a number that does not exist in the list it displays nothing, which is correct...)
How to get the right Value1-node????