Jump to content

Recommended Posts

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 by tiscavalcanti
Link to comment
Share on other sites

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:

  1. Checkbox is at 0.
  2. "IF" is satisfied.
  3. Checkbox is at 1.
  4. "ELSE" is satisfied.
  5. Checkbox is at 0 ("ELSE" always is 0).
  6. "IF" is satisfied again.
  7. Checkbox is at 0 again.
Edited by tiscavalcanti
Link to comment
Share on other sites

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>
  • Like 1
Link to comment
Share on other sites

 

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

 

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 by tiscavalcanti
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...