To get "answer24235X25X521", you could use "answer{input.sgqa}".
However, as you are seeing, EM-based substitutions are always dynamic (e.g. use the <span> element) when on the same page, so at present, that wouldn't work for your either. However, it should be possible to do this:
var input = document.getElementById(strip_tags("answer{input.sgqa}"));
Your question raises the broader question of whether some EM substitutions should be static, even when on the same page. The answer is probably "yes", but the development team needs to discuss this a bit.