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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...