Encoding strings using periodic table abbreviations
Any suggestions?


Yes, a few.

First off, split your function into parts (SRP), to separate the view (DOM elements and their values) from the logic (finding element names in strings).


var splits = fname.split("");
for (var i = 0; i &lt; splits.length; i++) {
    var onevalue = fname.indexOf(splits[i]);



That doesn't make much sense to me. Don't you expect onevalue == i? If not, you might annotate this explicitly and/or make the comparison. Maybe it's inside the "some code"?


var doublev = fname.substring(onevalue, onevalue + 2);
var triplev = fname.substring(onevalue, onevalue + 3);



Notice that these will have the same value as singlev in the last [two] iterations of your loop, where the end is outside of the string.


if (ellist[splits[i]] || ellist[doublev] || ellist[triplev]) {
    value = splits[i];
    if (ellist[doublev] || ellist[triplev]) {
        value = ellist[doublev];
        if (ellist[triplev]) {
            value = ellist[triplev];



Ouch. Simplify this to

if (triplev in ellist) {
    value = ellist[triplev];
} else if (doublev in ellist) {
    value = ellist[doublev];
} else if (splits[i] in ellist) { // are you sure you don't want `singlev`?
    value = splits[i];
}