Hello
Using AppGini 5.50
What you need to do is use an EventListener
You also need to ensure all fields you are going to 'listen' to have an id
Code: Select all
function yourfunctionname(){ //this is your function name - call it what you want
document.getElementById("elementid").addEventListener("blur",nextfunction, true); //elementid is the id of the field you watching, when it blurs then it runs the next function. This is actually watching a div element - found this easiest to do what I want
function nextfunction(){ // this is called by the bluring of the above div element - means user left field
if($j('#fieldid').val() == (17)){ //this value is the value of what is entered in the field referenced - as I only had one value to trap for I put it in. But you could have a call which gets the id and compares it to an array or whatever
$j('#fieldtohide').hide(); //this tells it to hide this field if the value == 17
} else {
$j('#fieldtohide').show(); //otherwise it tells it to show it
}
}
} //the code below here is for firefox browsers. They do not like blur and this resolves it with the focusout routine
$j(document).ready(function(){
$j('#fieldtohide').hide(); // I hid the field when the document was ready.
setTimeout(function() { $j('#divname').focusout(); }, 100);
});
Okay, what this does is the following:
When a user selects, in this case only, one specific value to be in the #fieldid field and leaves the div to go on to another div to fill in more values in the form, it runs nextfunction and looks at the value. If the value matches 17 it then hides this field.
Why? I had one group which did not want to participate in a certain function and thought they would get away with it by not saying anything directly. By doing this method I prevented their registrants from seeing another data entry field to select options which were really only for those who wanted to participate. (Basically one group said unless you lived in certain boundaries you could not do X.) This hiding ensured their members could not benefit from the program fully.
It was interesting because once this became known the person with this restrictive policy resigned from the sports group and the president and new person was all for the program.
I guess a few members complained they could not do X and when I was asked I explained why. Needless to say I then turned the code off.
I hope it all works as I had to dredge it up from an old document after I turned it off and stripped it out. As I also compact my code for faster loading I had not make it look pretty again.
If there is a problem let me know and I will look at it to see what I missed in typing it in above. Hope nothing was missed.
Alan