View Single Post
Old 06-27-2012, 12:34 PM   PM User | #3
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,907
Thanks: 10
Thanked 293 Times in 289 Posts
Dormilich is on a distinguished road
of course it somewhat depends on how modern it may be. e.g. Mozilla supports Iterators, which is (from the sound of it) best suited. however, it can also be done in plain old JS.
PHP Code:
// only tested in FF
var it Iterator([
    {
jp"食べる"en"eat"},
    {
jp"読む"en"read"},
    {
jp"行く"en"walk"},
]);

var 
loop = function()
{
    try {
        var 
obj it.next()[1];
        
this.textContent obj.en " => " obj.jp;
    }
    catch (
e) {
        
alert("end of iteration");
    }
}
// attached to a button
document.getElementById("test").addEventListener("click"looptrue); 
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Users who have thanked Dormilich for this post:
meridian (06-28-2012)