javascript - JS return's undefined when is checked and I change select option selected -



javascript - JS return's undefined when is checked and I change select option selected -

i have html js code:

<form action="/resize" method="get" name="resolutionform"> <select name="res" id="res" onchange="checkzoom(this.value); checkcut('centercropcheck')"> <option value="original"> original</option><option value="800x600">800x600</option> </select> <input type="checkbox" id="stretchcheck" name="stretch" onclick="verificastretch(this.id);">esticar <div id="results"> <span>original: </span> <span>200x200</span> <span>zoom: </span> <span>0x</span> <span id="zoom">0x</span></span> </div> </form> <script type="text/javascript"> function elembyid(id){ homecoming document.getelementbyid(id); } function checkzoom(v){ if(v == '200x200' || v == 'original'){ var zoom = '0x'; }else{ if(elembyid('stretchcheck').checked){ verificastretch('stretchcheck'); }else{ var novow = number(v.substr(0,v.lastindexof("x"))); var novoh = number(v.substr(v.lastindexof("x") +1, v.length)); //alert('novow'+novow+'novoh'+novoh); var tamzoomw = novow / 200; var tamzoomh = novoh / 200; if(tamzoomw < tamzoomh){ var zoom = (tamzoomw.length > 3? tamzoomw.tofixed(2) : tamzoomw)+'x'; }else{ var zoom = (tamzoomh.length > 3? tamzoomh.tofixed(2) : tamzoomh)+'x'; } } elembyid('zoom').innerhtml = zoom; } } function verificastretch(id){ var v = elembyid('res').value; if(v == '200x200' || v == 'original'){ checkzoom(v); }else{ if(elembyid(id).checked){ //alert('aqui'); var novow = number(v.substr(0,v.lastindexof("x"))); var novoh = number(v.substr(v.lastindexof("x") +1, v.length)); //alert('novow'+novow+'novoh'+novoh); var tamzoomw = novow / 200; var tamzoomh = novoh / 200; var zoom = (tamzoomw.length > 3? tamzoomw.tofixed(2) : tamzoomw)+'x '+(tamzoomh.length > 3? tamzoomh.tofixed(2) : tamzoomh)+'x'; alert(zoom); elembyid('zoom').innerhtml = zoom; }else{ checkzoom(v); } } } </script>

when stretch's checkbox checked, , alter selected alternative of select res, undefined in div id = "result", how can solve problem? in file code without such ';' because error occurred when copying.

after if-condition

if(elembyid('stretchcheck').checked){ verificastretch('stretchcheck'); }else{ … }

is finished , verificastretch has correctly set span zoom 4x 3x, span zoom overwritten undefined variable zoom:

elembyid('zoom').innerhtml = zoom;

i think want line within else clause.

you have found using debugger , stepping through code function checkzoom onwards.

javascript select checkbox undefined option

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -