javascript getElementById gives error in chrome but works fine in IE -
here javascript function :
function deletealert(tabstate){ var form = window.document.alertsform; var numofelements = form.elements.length; var okdelete = "false"; (i=0; < numofelements; i++) { if(form.elements[i].checked) { okdelete = "true"; break; }else{ okdelete = "false"; } } if(okdelete == "true") { //changpage("screen1b.html"); prototype form.action="/cpi/producer/myalerts/alertsgateway?jadeaction=ma06&tab="+tabstate; form.document.getelementbyid('deletealertsbutton').disabled=true; form.submit(); }else{ alert("please select 1 or more items delete."); } }
i 'm calling function in 2 jsps , code snippet same both (note same id values)
<input type=button value="delete" id="deletealertsbutton" title="delete" class=fbutton onclick="javascript:deletealert('<%=state %>');">
now works perfect both jsp in ie8 in chrome , gives error second jsp : uncaught typeerror: cannot read property 'getelementbyid' of undefined
please help.
your reference form.document incorrect. "document" outside form
so change:
form.document.getelementbyid('deletealertsbutton').disabled=true;
to
document.getelementbyid('deletealertsbutton').disabled=true;
Comments
Post a Comment