I have calling onclick event problem in dynamic label in .js

Discussion in 'JavaScript' started by htetlinsu, Jul 9, 2008.

  1. #1
    i want to call function when i click dynamic label in js file
    my code sample is here!

    var output='<form><table><tr>';
    for(var i=1;i<=page;i++){
    //var pgno=String(i);

    output+='<td><label id=\"'+i+'\"/ onclick=\"Display();\">'+i+'</td>';

    }
    output+='</tr></table></form>';
    document.write(output);
    function display(){
    document.write("hello");
    }


    but onclick event doesn't work.how can i call onclick event .:confused:
     
    htetlinsu, Jul 9, 2008 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You have a syntax error in the func name. It should be display(), not Display();
     
    xlcho, Jul 9, 2008 IP
  3. htetlinsu

    htetlinsu Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes.i change this syntax error but it does not active this onclick event.how can i do?please help me.
     
    htetlinsu, Jul 10, 2008 IP