Hello Forum,
i try to add a value to a textfield.
i have 3 radio buttons(NGN) with the value 1,2 and 3.
Only one can activate. When the radio button is activate, he must export the value 1 to a textfield (NGN_2). This textfield(NGN_2) is a part of a multiplication. This multiplication have the value 1 (radio button) and a value from an other textfield(NGN1) (for example the value 229 dollar).
I solve this problem with this code:
code textfield (NGN_2)
event.value = "";
if (this.getField("NBN").value == "1") {
event.value = 1;
}
if (this.getField("NBN").value == "2") {
event.value = 1;
}
if (this.getField("NBN").value == "3") {
event.value = 1;
}
but this multiplier (1 from the radio buttons) must edit later manually to an other multiplier.
Everytime i want to edit this multipler, it jumps back to 1.
I hope somebody can help me.
thanks al lot
sunny
I guess the code shown is in the Calculate event of the text field. As the Calculate event will happen every time something changes in your form, the value from the NBN field will be read and inserted, annihilating the manually entered value. You can overcome this by "pushing" from the radio button field (instead of "pulling" by the text field. You would add the following code to the MouseUp event of all three instances of the radio button field:
if (event.target.value != "Off") {
this.getField("NGN_2").value = event.target.value*1 ;
} else {
// what to do when the radio button is not checked yet
this.getField("NGN_2").value = 1 ;
// making sure that the calculation does not break down
}
Note that the second part is to make sure that there will be a valid (maybe wrong, but that would have to be adjusted) calculation in the form. You have to know what the default behavior should be.
HTH.
Max Wyss.