Hey beautiful community, I have this need to have first letter of my word field in my hint field, is there any way to automate it ?
There was such a code in one of the publicly available decks. The first and last letter of the field.
<div id="term">{{Front}}</div>
<script>
var dashes = document.getElementById("term").innerHTML;
dashes = dashes.slice(0, dashes.length);
document.getElementById("term").innerHTML = dashes[0] + " ";
for (var j = 0; j < dashes.length-2; j++){
document.getElementById("term").innerHTML += "-";
}
document.getElementById("term").innerHTML += " " + dashes[dashes.length - 1];
</script>
If you don’t need the last letter and a hint of the length of the “-” field, then use
<div id="term">{{Front}}</div>
<script>
var dashes = document.getElementById("term").innerHTML;
dashes = dashes.slice(0, dashes.length);
document.getElementById("term").innerHTML = dashes[0];
</script>
Thank you so much for replying, can you please elaborate how exactly i need to use this script, the “front” field name i deduce need to be changed with my target field of Word i want the hint letter, right ? And where i need to assign hint field to contain hint letter ? My field for target word and hint name “Word” and “Hint” respectively.
You don’t need a separate field for this. You just use the {{Word}} field a few times. Leave everything as you have it and just add it to the template
<div id="term">{{Word}}</div>
<script>
var dashes = document.getElementById("term").innerHTML;
dashes = dashes.slice(0, dashes.length);
document.getElementById("term").innerHTML = dashes[0];
</script>
If you want to make a hint out of it {{hint:…}
Hint Fields
{{#Word}}
<a class=hint href="#"
onclick="this.style.display='none';document.getElementById('hint4753594160').style.display='inline-block';return false;">
Show Back</a><div id="hint4753594160" class=hint style="display: none"><div id="term">{{Word}}</div></div>
{{/Word}}
<script>
var dashes = document.getElementById("term").innerHTML;
dashes = dashes.slice(0, dashes.length);
document.getElementById("term").innerHTML = dashes[0];
</script>
I tried your first script put it at front side and it showed first letter of word as hint but it was not hidden, and when i review the card the note deleted itself, eventually your latter script worked exactly as i wanted to, hopefully it this script wont be a problem to my whole deck i am little apprehensive because i dont know how exactly these script works but for now everything seems okay and thank you so much for your aid.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.