JavaScript forEach loop works in all webbrowser but Internet Explorer -


i've managed loop working in browsers apart internet explorer (which doesn't seem support foreach).

the javascript cpde:

function validate() {     var msg = '';     var = 0;      arr.foreach(         function validateinfo(){             if (getrbtnname('yesno_' + + '_0' == "" && 'yesno_' + + '_0') == "") {                 msg = 'please select yes/no users'             }             if (msg == '') {                 return true;             }             is++;         }     )      if (msg == '') {         reloadpage();     }      if (msg != '') {         alert(msg);         return false;     } }   function reloadpage(){     window.location.reload() } 

the array being set in php file rather passed in. it's being set using:

<script type="text/javascript">     var arr = <?php echo json_encode($arr) ?>; </script> 

just place shim mdn @ beginning of scripts:

if ( !array.prototype.foreach ) {   array.prototype.foreach = function(fn, scope) {     for(var = 0, len = this.length; < len; ++i) {       fn.call(scope, this[i], i, this);     }   } } 

Comments

Popular posts from this blog

ruby on rails - Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/ -

c++ - nodejs socket.io closes connection before upgrading to websocket -

java - What is the equivalent of @Value in CDI world? -