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
Post a Comment