calmchess Posted April 2, 2013 Share Posted April 2, 2013 I have the following code and for some reason the last line before the alert will only execute properly if I have the alert there without the alert it doesn't work. Why? I have seen this phenomenon other places in my codes too does it indicate anything significant when I debug code? var select0 = document.getElementById("subhead00"); var select00=select0.options; var spansinputs0=document.getElementsByClassName(""+slotid0+""); var getvalueinner0=spansinputs0[0].value; switchID0=0; subID0=""; if(dbid00<=12){ select00=getvalueinner0; alert(); Quote Link to comment https://forums.phpfreaks.com/topic/276451-a-lil-help-with-an-alert-issue/ Share on other sites More sharing options...
Psycho Posted April 2, 2013 Share Posted April 2, 2013 Hmm, that code is not valid - there is no closing curly brace to match the opening curly brace after the if() condition. I assume there is more code since the line before the alert is simply an assignment and doesn't do anything. So, you must have other code that uses that value which is not working as you expect. Assuming the format errors above are just due to a lack of the entire code the only thing that comes to mind is that some of the code is dependent upon some other process completing first and the alert allows that to complete before you click "OK". It could even be an issue with field focus. Once the alert pops up and you click OK your focus may change allowing the process to complete successfully. Basically, you haven't shared enough of the code to really understand the problem. Quote Link to comment https://forums.phpfreaks.com/topic/276451-a-lil-help-with-an-alert-issue/#findComment-1422547 Share on other sites More sharing options...
calmchess Posted April 2, 2013 Author Share Posted April 2, 2013 change:function(e){ e.preventDefault(); var slotid0=e.target.getAttribute("id"); var slotid00=slotid0; var bind1=""; var dbid0 = ((slotid0.length>6)?slotid0.substring(5,7):slotid0.substring(5,); var dbid00=Number(dbid0)+1; var select0 = document.getElementById("subhead00"); var select00=select0.options; var spansinputs0=document.getElementsByClassName(""+slotid0+""); var getvalueinner0=spansinputs0[0].value; switchID0=0; subID0=""; if(dbid00<=12){ select00=getvalueinner0; bind0=getvalueinner0; switchID0=2; }else{ switchID0=1; subID0=select0.value; //dbid00=dbid00%12; alert(subID0); //if(dbid00==0){dbid00=12;} } //change sub values if(select0.value!="Kies Categorie"){ bind0=select0.value; } for(var j=12;j<24;j++){ var spansinputs0=document.getElementsByClassName("catid"+""+j+""); var getvalueinner0=((spansinputs0[0].value)?spansinputs0[0].value:spansinputs0[0].innerHTML); if(getvalueinner0!=""){ bind1=bind1+getvalueinner0+":::"; } } if(document.getElementsByTagName("input").length>0){ ajax.callserv('http://localhost/elance/admin_console/secure_php/changecustregcats.php' adminconsoleui.refreshspan,bind0,bind1,slotid0,dbid00,subID0,switchID0); } }, Quote Link to comment https://forums.phpfreaks.com/topic/276451-a-lil-help-with-an-alert-issue/#findComment-1422548 Share on other sites More sharing options...
calmchess Posted April 2, 2013 Author Share Posted April 2, 2013 oh allright sorry here is all the code for the function Quote Link to comment https://forums.phpfreaks.com/topic/276451-a-lil-help-with-an-alert-issue/#findComment-1422549 Share on other sites More sharing options...
Solution calmchess Posted April 3, 2013 Author Solution Share Posted April 3, 2013 fixed it by adding an option to the select properly select0.options[0] = new Option(getvalueinner0, getvalueinner0); Quote Link to comment https://forums.phpfreaks.com/topic/276451-a-lil-help-with-an-alert-issue/#findComment-1422555 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.