tiscavalcanti Posted December 21, 2015 Share Posted December 21, 2015 (edited) I want to know, if is there any way to javascript change (switch) between two values (1 and 0) in a Checkbox, A code without resulting in a fixed value, its function becomes only toggle value. For example, I need put this in a Property: if (thisComp.layer("Logo").transform.opacity==100) "My Checkbox" (switch) else 0; After Effects Expression Edited December 21, 2015 by tiscavalcanti Link to comment Share on other sites More sharing options...
davej Posted December 21, 2015 Share Posted December 21, 2015 Huh? So why not just write a function to do that? 1 Link to comment Share on other sites More sharing options...
tiscavalcanti Posted December 21, 2015 Author Share Posted December 21, 2015 Huh? So why not just write a function to do that? Yes. Can be. Link to comment Share on other sites More sharing options...
tiscavalcanti Posted December 21, 2015 Author Share Posted December 21, 2015 Huh? So why not just write a function to do that? I really don't know do this. Could you help me anyway? Link to comment Share on other sites More sharing options...
davej Posted December 21, 2015 Share Posted December 21, 2015 You need to carefully describe what you want, because it isn't perfectly clear. 1 Link to comment Share on other sites More sharing options...
tiscavalcanti Posted December 21, 2015 Author Share Posted December 21, 2015 (edited) You need to carefully describe what you want, because it isn't perfectly clear. I want a code which switch a property, that is, toggle between two fixed values; (Checkbox - 1 or 0) If a determined condition is true. For example: a = 1; b = 2; if (a > "CheckBox switch for 1 (if was at 0) or switch for 0 (if was at 1)"; else 0; If "ELSE" is satisfied, and get back to "IF" satisfied; The Checkbox will be with the inverse value of what was before "ELSE". That's what I want. In another example. I will create a situation, step by step: Checkbox is at 0. "IF" is satisfied. Checkbox is at 1. "ELSE" is satisfied. Checkbox is at 0 ("ELSE" always is 0). "IF" is satisfied again. Checkbox is at 0 again. Edited December 21, 2015 by tiscavalcanti Link to comment Share on other sites More sharing options...
davej Posted December 21, 2015 Share Posted December 21, 2015 Huh? Maybe... <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>title</title> <style> </style> <script> window.onerror = function(a,b,c){ alert('Javascript Error: '+a+'\nURL: '+b+'\nLine Number: '+c); return true; } </script> </head> <body> <input type="checkbox" id="chk01"/> <br/> <input type="button" id="btn1" value="Toggle"/> <script> 'use strict'; function togglechk(id){ var chk = document.getElementById(id); chk.checked = (chk.checked == true)? false : true; }//end of func document.getElementById('btn1').onclick = function(){ togglechk('chk01');}; </script> </body> </html> 1 Link to comment Share on other sites More sharing options...
tiscavalcanti Posted December 21, 2015 Author Share Posted December 21, 2015 Huh? Maybe... <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>title</title> <style> </style> <script> window.onerror = function(a,b,c){ alert('Javascript Error: '+a+'\nURL: '+b+'\nLine Number: '+c); return true; } </script> </head> <body> <input type="checkbox" id="chk01"/> <br/> <input type="button" id="btn1" value="Toggle"/> <script> 'use strict'; function togglechk(id){ var chk = document.getElementById(id); chk.checked = (chk.checked == true)? false : true; }//end of func document.getElementById('btn1').onclick = function(){ togglechk('chk01');}; </script> </body> </html> Okay! I will make some tests. Thank you very, very much! Link to comment Share on other sites More sharing options...
tiscavalcanti Posted December 21, 2015 Author Share Posted December 21, 2015 (edited) Huh? Maybe... <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>title</title> <style> </style> <script> window.onerror = function(a,b,c){ alert('Javascript Error: '+a+'\nURL: '+b+'\nLine Number: '+c); return true; } </script> </head> <body> <input type="checkbox" id="chk01"/> <br/> <input type="button" id="btn1" value="Toggle"/> <script> 'use strict'; function togglechk(id){ var chk = document.getElementById(id); chk.checked = (chk.checked == true)? false : true; }//end of func document.getElementById('btn1').onclick = function(){ togglechk('chk01');}; </script> </body> </html> Perfect, friend; Work very cool! Exactly! Edited December 21, 2015 by tiscavalcanti Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now