Thank you for the responses.
INVERSE APPROACH
DISPLAY IT BUT HIDE IF ALL ARE EMPTY
I will start with this approach first. I have gotten this to work. I just had to make an adjustment though.
snoyes coding suggestion :
<div id='theElement'>ELEMENT</div>
{{^field1}}{{^field2}}{{^field3}}
<style>
#theElement { display: none; }
</style>
{{/field1}}{{/field2}}{{/field3}}
I think that the order of the fields has to be reversed in the closing line :
<div id='theElement'>ELEMENT</div>
{{^field1}}{{^field2}}{{^field3}}
<style>
#theElement { display: none; }
</style>
{{/field3}}{{/field2}}{{/field1}}
So that you have this pattern happening :
1 2 3
3 2 1
INITIAL APPROACH
HIDE IT BUT DISPLAY IF ANY HAVE CONTENT
<div id='theElement' style="display: none;">ELEMENT</div>
<script>
theElement = document.getElementById('theElement');
{{#field1}}theElement.style.display = 'block';{{/field1}}
{{#field2}}theElement.style.display = 'block';{{/field2}}
{{#field3}}theElement.style.display = 'block';{{/field3}}
</script>
I tried this as well but only seem to have gotten it to work partially.
I suppose I could do what I need to do with my Anki decks with the inverse approach. But I would still like to know how to make the initial approach work. It might be good for any possible Forum readers to know what is going on as well.
I created experiment decks to try out the two coding approaches. What happened with the initial approach, to hide the element and display if any fields have content, is that of the two elements that were to display if any fields had content, only the first element did as it was supposed to. The second element never displayed.
The difference between the aformentioned two elements in the coding was that :
- the first element that worked as it should, it occurred prior to the divs with the relevant fields
- the second element which never appeared, it occurred after the divs with the relevant fields. In fact, placing that element only after one div with relevant fields caused it to not work properly.
Am I applying the coding correctly?
MY CODING FOR “HIDE ELEMENT BUT DISPLAY IT IF ANY FIELD HAS CONTENT” WHICH ISN’T WORKING FOR ME :
<!================================================
BACK CARD FOR: HIDE ELEMENT BUT DISPLAY IT IF ANY FIELD HAS CONTENT
=================================================>
<!DOCTYPE html>
<html>
<head>
<meta name= "viewport" content= "width=device-width, initial-scale=1.0" >
</head>
<body>
<!------------------------------------------------------------------------------------------------------>
<!__________________________________________________
BACK CARD LANDSCAPE VIEW
___________________________________________________>
<!------------------------------------------------------------------------------------------------------>
<! div 1 . . . >
<div class= "port" >
<!------------------------------------------------------------------------------------------------------>
<! Hide the element, but display it if any fields have content.
APPEAR is the id name for the ID Attribute. This can be any text. I don't know about other characters.
In this case you just want to get the two violet lines to disappear if all fields are empty. The div's disappear as per their contained field containing content or not.
THE PROBLEM WITH THIS CODING IS THAT THE SECOND VIOLET LINE NEVER APPEARS. THE FIRST VIOLET LINE DOES WHAT IT'S SUPPOSED TO, IT APPEARS IF ANY FIELD HAS CONTENT AND DISAPPEARS IF NONE OF THE FIELDS HAVE CONTENT.>
<! space >
<div style= "height: 5vw;" class= "port " ></div>
<! violet line
THIS WILL APPEAR IF ANY FIELDS HAVE CONTENT >
<div id= 'APPEAR' style="display: none;">
<div style= "height: .8vw;" class= "bgviolet" ></div>
</div>
<! THE THREE DIVS WITH THE RELEVANT FIELDS>
{{#field 1}}
<div style= " font-family: segl; font-size: 6vw; text-align: center; padding: .2vw 0vw .45vw 0vw;" class= "grey45 segl"> {{field 1}} </div>
{{/field 1}}
{{#field 2}}
<div style= " font-family: segl; font-size: 6vw; text-align: center; padding: .2vw 0vw .45vw 0vw;" class= "grey45 segl"> {{field 2}} </div>
{{/field 2}}
{{#field 3}}
<div style= " font-family: segl; font-size: 6vw; text-align: center; padding: .2vw 0vw .45vw 0vw;" class= "grey45 segl"> {{field 3}} </div>
{{/field 3}}
<! violet line
THIS WILL APPEAR IF ANY FIELDS HAVE CONTENT
This second violet line however will not appear no matter whether the fields have content or not. >
<div id= 'APPEAR' style="display: none;" >
<div style= "height: .8vw;" class= "bgviolet" ></div>
</div>
<! space >
<div style= "height: 1vw;" class= "port " ></div>
<!------------------------------------------------------------------------------------------------------>
</div>
<! . . . div 1 >
<!------------------------------------------------------------------------------------------------------>
<script>
APPEAR = document.getElementById('APPEAR');
{{#field 1}}APPEAR.style.display = 'block';{{/field 1}}
{{#field 2}}APPEAR.style.display = 'block';{{/field 2}}
{{#field 3}}APPEAR.style.display = 'block';{{/field 3}}
</script>
<!------------------------------------------------------------------------------------------------------>
</body>
</html>
<!__________________________________________________>
<!__________________________________________________>
<!__________________________________________________>
MY CODING FOR “DISPLAY ELEMENT BUT HIDE IT IF ALL FIELDS ARE EMPTY” WHICH IS WORKING FOR ME :
<!================================================
BACK CARD FOR: DISPLAY ELEMENT BUT HIDE IF ALL FIELDS ARE EMPTY
=================================================>
<!DOCTYPE html>
<html>
<head>
<meta name= "viewport" content= "width=device-width, initial-scale=1.0" >
</head>
<body>
<!------------------------------------------------------------------------------------------------------>
<!__________________________________________________
BACK CARD LANDSCAPE VIEW
___________________________________________________>
<!------------------------------------------------------------------------------------------------------>
<! div 1 . . . >
<div class= "port" >
<!------------------------------------------------------------------------------------------------------>
<! Display the element, but hide it if all fields are empty.
DISAPPEAR is the id name for the ID Attribute. This can be any text. I don't know about other characters.
In this case you just want to get the two violet lines to DISAPPEAR if all fields are empty. The div's DISAPPEAR as per their contained field containing content or not. >
{{^field 1}}{{^field 2}}{{^field 3}}
<style>
#DISAPPEAR { display: none; }
</style>
{{/field 3}}{{/field 2}}{{/field 1}}
<! space >
<div style= "height: 5vw;" class= "port " ></div>
<! violet line
THIS WILL NOT APPEAR IF ALL FIELDS ARE EMPTY >
<div id='DISAPPEAR'>
<div style= "height: .8vw;" class= "bgviolet" ></div>
</div>
<! THE THREE DIVS WITH THE RELEVANT FIELDS>
{{#field 1}}
<div style= " font-family: segl; font-size: 6vw; text-align: center; padding: .2vw 0vw .45vw 0vw;" class= "grey45 segl"> {{field 1}} </div>
{{/field 1}}
{{#field 2}}
<div style= " font-family: segl; font-size: 6vw; text-align: center; padding: .2vw 0vw .45vw 0vw;" class= "grey45 segl"> {{field 2}} </div>
{{/field 2}}
{{#field 3}}
<div style= " font-family: segl; font-size: 6vw; text-align: center; padding: .2vw 0vw .45vw 0vw;" class= "grey45 segl"> {{field 3}} </div>
{{/field 3}}
<! violet line
THIS WILL NOT APPEAR IF ALL FIELDS ARE EMPTY >
<div id='DISAPPEAR'>
<div style= "height: .8vw;" class= "bgviolet" ></div>
</div>
<! space >
<div style= "height: 1vw;" class= "port " ></div>
<!------------------------------------------------------------------------------------------------------>
</div>
<! . . . div 1 >
<!------------------------------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------------------------------>
</body>
</html>
<!__________________________________________________>
<!__________________________________________________>
<!__________________________________________________>
I’m also appending to this comment the Anki .apkg files for these two experiment decks if that will help. Oh, it looks like I can’t append .apkg files.
If you think it would be helpful, I could also append the MS Word files containing the coding for the front and back cards as well as the styling card. I do my coding in MS Word files (which seems to work provided you do the coding a certain way) and I color code the coding in my own way which helps to make it be more easily made out.