I’m very new to Javascript.

I’m very new to Javascript.

Can anyone help and let me know where is exactly my mistake in below code.

I have a panel with 5 text items and trying to update the value via JS.

var c = LL.getEvent().getContainer();

var pnl = c.getItemByName(‘pnlPrayer’).getContainer();

var prayernames = [“lblFajrTime”, “lblZuhrTime”, “lblAsrTime”, “lblMagribTime”, “lblIshaTime”];

var prayertimes = “05:40,12:20,03:40,06:50,08:20”;

prayertimes.split(“,”);

for (i = 0; i = 5; i++) {

var lbl = pnl.getItemByName(prayernames[i]);

lbl.setLabel(prayertimes[i]);

}

]]>

5 Commentsto I’m very new to Javascript.

  1. Anonymous says:

    < ![CDATA[

    split returns the array, it does not change the var you call it on afaik

    ]]>

  2. Anonymous says:

    < ![CDATA[

    I think you need to save the table returned by prayertimes.split(“,”) :


    var tab_time = prayertimes.split(“,”);



    Then use it in the for loop, by replacing prayertimes[i] by tab_time[i]

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Bogdan Tautu​ Benoît de Chezelles​ Thanks a lot that has solved th issue of the split and array. But still there is one more issue and I think it is with the loop. When I run the script the whole launcher get stuck and then a (not responding) message appears to force close LL.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    This is how my new code looks



    var c = LL.getEvent().getContainer();




    var pnl = c.getItemByName(‘pnlPrayer’).getContainer();



    var prayernames = [“lblFajrTime”, “lblZuhrTime”, “lblAsrTime”, “lblMagribTime”, “lblIshaTime”];



    var prayertimes = “05:40,12:20,03:40,06:50,08:20”;



    var prayertimes_table = prayertimes.split(“,”);




    var i;



    for (i = 0; i = 4; i++) {



    var lbl = pnl.getItemByName(prayernames[i]);



    lbl.setLabel(prayertimes_table[i]);



    }

    ]]>

  5. Anonymous says:

    < ![CDATA[

    OK. OK. I fixed it.



    The mistake was in i = 4, it should be i < 5

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *