Hi Guys,
Im trying to make a button which will show/hide a 'BankDetails' subform when clicked.
When I click the button, it hides the subform and changes the button text to 'Show' (working correctly) but when I click it again it does nothing.... it isnt seeing the 'else if' statement.
I'm new to scripting so any help would be greatly appreciated!
form1.BankDetails_Title.Table1.HeaderRow.Button2::mouseUp - (JavaScript, client)
if(this.parent.parent.parent.parent.BankDetails.presence = "visible")
{
this.parent.parent.parent.parent.BankDetails.presence = "hidden";
this.resolveNode("caption.value.#text").value = "Show";
}
else if( this.parent.parent.parent.parent.BankDetails.presence = "hidden")
{
this.parent.parent.parent.parent.BankDetails.presence = "visible";
this.resolveNode("caption.value.#text").value = "Hide";
}
Solved! Go to Solution.
Views
Replies
Total Likes
You have to use an equality operator '==' in your if statement when comparing two values. The equality operator compares the left and right operands' values and returns a boolean (true or false). You are using an assignment operator '=', which takes the right side operand and assigns its value to the left and returns that value.
So if your using '=' in your if statement then you would normally be assigning strings or positive numbers which when evaluated, will always return true (such as in your case).
Kyle
Views
Replies
Total Likes
if there are only 2 possible states (ie. visible or hidden) then you don't need an 'else if' just an 'else' statement.
Thanks whyisthisme,
I did try to use the else statement instead but had no luck...
form1.BankDetails_Title.Table1.HeaderRow.Button2::mouseUp - (JavaScript, client)
if(this.parent.parent.parent.parent.BankDetails.presence = "hidden"){
this.parent.parent.parent.parent.BankDetails.presence = "visible";
this.resolveNode("caption.value.#text").value = "Hide";
}
else {
this.parent.parent.parent.parent.BankDetails.presence = "hidden";
this.resolveNode("caption.value.#text").value = "Show";
}
It works when I initially click the button (will show the hidden subform) but when i click it the second time it does not hide the subform again.
Views
Replies
Total Likes
You have to use an equality operator '==' in your if statement when comparing two values. The equality operator compares the left and right operands' values and returns a boolean (true or false). You are using an assignment operator '=', which takes the right side operand and assigns its value to the left and returns that value.
So if your using '=' in your if statement then you would normally be assigning strings or positive numbers which when evaluated, will always return true (such as in your case).
Kyle
Views
Replies
Total Likes
Thanks Kyle!
worked perfectly!
I used:
if( | this.parent.parent.parent.parent.BankDetails.presence == "hidden" |
Thanks again!
Views
Replies
Total Likes