Auto-Populate Field With Other Field(s)?

I’m using code in my card template to randomize what is shown in the field {{Multi}}. Essentially, I am taking what I’ve already put into 2~4 other fields then copying & pasting them into the {{Multi}} field and separating them with an “|” symbol, and Anki randomly shows something between the |'s.

I was wondering if there was a way to have the {Multi}} field autofill automatically when I enter things into the other fields? It would be ideal to not have to copy/paste multiple times every new note.

Is it an option to modify the JS to randomise between these different fields instead of putting everything into one {{Multi}}?

1 Like

To clarify on this, JS could be used instead of the Multi field if the 2-4 fields are always copied (or you can add extra fields for each of those fields to declare whether to use it or not, with empty being do not use and not empty being use). It won’t be useful in the exceptional cases, obviously.

Could you show an example note?

1 Like

Sure, here are some screenshots I took:




I don’t know about the JS because I basically got the code from a comment on this add-on: https://ankiweb.net/shared/info/1940275457

I understand what you are going for this approach, but I would highly suggest you to split them off into their own card types. Yes, your workload is going to be more than if you use this, but it would be better than the alternative.
Suppose you forgot the Kanji for one (part of question) but you remember all the other ones. You aren’t guaranteed to see the Kanji as a question the next couple of times you see it.

If you still want to proceed with this approach, here’s how to do it.

Assuming that all the fields that I can see here are used, change the code inside the ‘function’ to be this

list = [`{{Each field name here}}`,...] (repeat the fields that you need in this format, separating each with a , )
document.getElementById(id).replace(list[Math.floor(Math.random()*list.length)])

Sorry, I may be misunderstanding, but I have a couple points:

1.) I’m not sure I understand the potential problem you are presenting? I am not using these cards to learn Japanese; I am using the Japanese I know to remind me of simple words/phrases I’ve already learned in other languages. Forgetting the kanji at this point is not really an issue.

2.) Looking again now, I’ve realized that I did not provide the Meaning notes which may be where the misunderstanding is coming from. I’m not as concerned with the {{マルチ}} field; it’s mostly there for convenience and since my thinking was that there can be many words in Japanese that can be considered appropriate depending on the contexts between the languages. Examples of these notes might’ve helpful so apologies for that. I have now included these screenshots also.





I’ve adjusted the code in the way I think you are suggesting, but it does not appear to be operating as desired:

My concern is that you’re not being ‘atomic’. You’re merging multiple cards into one.
Your pass and fail condition is not a singular thing. You might excel at one conversion, but not be very good at another.

You only need the names of the field, you have included the formatting as well.

I may need a more specific explanation for what I am doing wrong.

Whoops, I seem to have accidentally omitted a word.
It should be document.getElementById(id).innerHTML.replace