Copy link to clipboard
Copied
Can someone tell me why this code isnt working? (I tried putting the code in the text box "no addon selected" under validation and custom calculation script)
Basically when the check boxs "vehicle car" "car int" and "addon - no check" are selected I want a text box named "no addon selected" to disply visible otherwise remain hidden:
if (this.getField("vehicle car").value=="Yes"
||
this.getField("car int").value=="Yes"
||
this.getField("addon - no check").value=="Yes")
{this.getField("no addon selected").display = display.visible; } else {this.getField("no addon selected").display = display.hidden; }
if the check boxs "vehicle car" "car int" and "addon - yes check" are selected I want a drop down named "car int drop down" to disply visible otherwise remain hidden.
Copy link to clipboard
Copied
Where does you use the script?
Copy link to clipboard
Copied
Putting it in the field's validation event will not work because that only happens when you change that field's value. It should work if you place it as the calculation script, though. Are you seeing any error messages in the JS Console?
Copy link to clipboard
Copied
I got it to work with this script put in the custom calculation field in the text box "no addon selected"
event.target.hidden
=!(this.getField("vehicle car").isBoxChecked(0)
&& this.getField("car int").isBoxChecked(0)
&& this.getField("addon - no check").isBoxChecked(0) );
BUT
when I add this to the same text box custom calculation field it only ends up working for one of the two scripts
event.target.hidden
=!(this.getField("vehicle car").isBoxChecked(0)
&& this.getField("car ext").isBoxChecked(0)
&& this.getField("addon - no check").isBoxChecked(0) );
I need the same text box (no addon selected) to show when "vehicle car" "car int" and "addon - no check" are selected but if "vehicle car" "car ext" and "addon - no check" are selected I need the same text box to show (no addon selected) and thats not working now.
Copy link to clipboard
Copied
What happens when you use the script on this field?
Copy link to clipboard
Copied
the first part works but not the second part
Copy link to clipboard
Copied
@try67
in a secondary follow up question:
I have a checkbox named "engine" I need the export value to be 55 when it is selected WITH a checkbox named "car ext" otherwise the value when selected is 35
I have this code:
if(this.getField("car ext").isBoxChecked(0)) this.getField("engine").value = "55"; else {this.getField("engine").value = "35"; }
this works BUT I need to get these codes added to the same checkbox:
if(this.getField("mid ext").isBoxChecked(0)) this.getField("engine").value = "55"; else {this.getField("engine").value = "35"; }
if(this.getField("full ext").isBoxChecked(0)) this.getField("engine").value = "55"; else {this.getField("engine").value = "35"; }
so basically if "car ext" is selected WITH "engine" "engine" value will be 55. If "car ext" is NOT checked then the value of "engine" is 35 when checked. And then the same thing with "mid ext" and "full ext"
I cant use the && option because I dont want it all three (car ext, mid ext and full ext) to have to be selected for it to show 55. I want an "or" statement somehow, I've tried multiple things from my basic knowledge of java and cant figure this out. I need help on this ASAP as this is a project due soon and this is all I need to do to figure it out.
Thanks!
Copy link to clipboard
Copied
If I get you correct you want to change 'engine' checkbox export value depending on another checkbox being checked? You can do it with exportValues, and maybe put code in a text field, but you would need to make sure other checkboxes are checked before 'engine' for it to work properly and to not get unexpected behavior from checkboxes.
I wouldn't advise to do that especially if other users will be using that form. If you are using engine checkbox export value in calculation it would be better to use variables inside those calculations to set values that you need.
Copy link to clipboard
Copied
Agreed. Changing the export value is not the way to go. You just need to handle it differently in your calculation based on the other conditions.
Copy link to clipboard
Copied
@Nesa Nurani @try67 yes! The previous checkbox shows the new field. So clicking "vehicle car" unhides "car ext" which unhides "engine"
however if the variable method is more sound I can do that. I've never used variables before. I’m very new to java and only have a basic understanding, are either on of you able to provide me with a code useing my example to get me started? Once I’m steered in the right direction I should be ok. If you could it would help me out immensely!
thanks!
Copy link to clipboard
Copied
There is a lots of ways to do this, it depends on the rest of your calculations but you could do something like this:
var x = 0;
if(this.getField("car ext").valueAsString != "Off" && this.getField("engine").valueAsString != "Off"){
x = 55;}
else if(this.getField("engine").valueAsString != "Off"){
x = 35;}
Now you can use x in the rest of your code.
I'm not sure what you try to achive?
Above you write: clicking "vehicle car" unhides "car ext" which unhides "engine" that means to be able to check 'engine', 'car ext' must be checked and you want if 'car ext' is uncheked 'engine' value is 35 when checked, so in order to do that you would need: check 'car vehicle' -> check 'car ext' -> check 'engine' and go back to uncheck 'car ext'?
Copy link to clipboard
Copied
So I have 3 layers of checkboxes
Vehicle Type: Car, Mid, Full
Package type: interior, exterior, full (which will only display when vehicle type is selected)
Addons: "engine, paint, surcharge" (whick will only display once vehicle type and package type are selected)
example:
if car and exterior are selected I want engine to display as 55
but
if mid and exterior are selected I want the same check box engine to display 35 (or whatever number)
but
if full and exterior are selected I want the same check box engine to display 75 (or whatever number)
and the same concept for the other car types and packages
does that code work for that example? Do I put that as a mouse up javascript on the engine button?
would "x" be the export value I assign to the engine checkbox in the properities settings?
Copy link to clipboard
Copied
Where do you want to show 55 or 75...etc in text field?
Copy link to clipboard
Copied
Yes called "addon total" which may be required to calculate and add other selected boxes together.
should I pm you my file so you can see what I’m trying to do? Would that be easier?
Copy link to clipboard
Copied
Sure, send me a file.