Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScript function not working for 0 value in array
    primarykey
    data
    text
    <p>This function is meant to find the highest variable in a list of variables, which have five id letters, and one number. It works fine with all the other slots, 2, 3, 4, 5, 6, 7, 8, 9, 10, but not 1. I need another set of eyes here.</p> <p>The getVer function takes the number from the id; so ImpHt1 with getVer would be 1, while getShtNm gets ImpHt.</p> <pre><code>function find_max_feat(array_input,ShtNm) { if (String(array_input[0]).length == 1) { var max = 0; } else { var max = getVer(array_input[0]); } var maxver = 0 var len = array_input.length; for (var i = 0; i &lt; len; i++) { if (String(array_input[i]).length &gt; 1) { if (getShtNm(String(array_input[i])) == ShtNm) { if (getVer(String(array_input[i])) &gt; maxver) { var max = array_input[i]; var maxver = getVer(String(array_input[i])); } } } } return max; } </code></pre> <p>0,DmnHt1_0,AltFm1_,0,0,0,0,0,0,0</p> <p>An example of the array, which is why getVer is needed.</p> <p>This is for a sheet generator, to be clear, but I've been working on the entire thing for at least a few days now, maybe even a week or weeks of on and off work.</p> <p>The array above is generated any time a feat is selected, and the find_max_feat array is used to find the highest version in a group; it operates off of an infinite loop since nothing else I did could get it to work the way I wanted it to.</p> <pre><code>function checkFeats() { updateFeatsel(); t=setTimeout("checkFeats()",1000); } function updateFeatsel() { curselarray = new Array(); var selinc = 1; while (selinc &lt;= 10) { var selincar = selinc - 1; var selid = document.getElementById(String('ftlst' + selinc)); if (getVer(selid.options[selid.selectedIndex].title)) { curselarray[selincar] = selid.options[selid.selectedIndex].title; } else { curselarray[selincar] = 0; } selinc++; } document.getElementById('debug1').innerHTML = curselarray.valueOf(); featSelch('hlthm','ImpHt',healthom); featSelch('strdmgm','ImpPd',Strpdom); featSelch('strwhtm','ImpLi',Strwhtom); featSelch('strsltm','EnhIt',StrSltom); featSelch('endsurm','ImpEn',EndSurom); featSelch('endsokm','ImpDf',EndSokom); featSelch('intelmpm','ImpMg',Intelmom); featSelch('willsokm','ImpMs',Willsokom); featSelch('luckrllm','ImpLu',Lukrllom); featSelch('luckpntm','EnhLu',Lukpntom); featSelch('hlthbn','DmnHt',0); featSelch('strbn','SupSt',0); featSelch('luckbn','DmnLu',0); featSelch('endbn','Armor',0) document.getElementById('debug2').innerHTML = find_max_feat(curselarray,'DmnHt'); updateAmounts(); } function featSelch(sid,fshtnm,defval) { return document.getElementById(sid).innerHTML = getFeatvalue(fshtnm,defval); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload