Script Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsrinivasan
    New Member
    • Mar 2007
    • 221

    Script Problem

    Hi,

    Im creating dynamic Row in javascript. I did it. But now i want call some function, when i click that <td>. I do not know how to do it. Plz help me.

    Thanks,
    Srinivasan r.
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    does not TD support onclick event firing?

    plz try with this.
    i think this ll work.
    best of luck.

    kind regards.
    dmjpro.

    Comment

    • rsrinivasan
      New Member
      • Mar 2007
      • 221

      #3
      Originally posted by dmjpro
      does not TD support onclick event firing?

      plz try with this.
      i think this ll work.
      best of luck.

      kind regards.
      dmjpro.
      Hi,
      Then which event we can use for TD. OnClick event is worked, when im creating table staticaly. But i cant do it in script. Thats why im asking you.

      Thanks,
      Srinivasan r.

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        hmmmm .......

        if anything wrong with my attitude can i get the dynamic row generation code and the function which u want to fire on clicking a TD?????

        then i think i ll correct ur code.

        kind regards.
        dmjpro.

        Comment

        • rsrinivasan
          New Member
          • Mar 2007
          • 221

          #5
          Originally posted by dmjpro
          hmmmm .......

          if anything wrong with my attitude can i get the dynamic row generation code and the function which u want to fire on clicking a TD?????

          then i think i ll correct ur code.

          kind regards.
          dmjpro.
          This is the function to generate dynamic TD. I can set width and data. But i cant set event for this. I set Bold where i set the event.

          function dealMenuDown()
          {
          document.getEle mentById('imgDe al').src='image s/Deal_On.gif';
          document.getEle mentById('imgSe curityAdmin').s rc='images/SecurityAdminOf f.gif';

          var myTable = document.getEle mentById('sub_t able_id');
          var myNewRow = document.getEle mentById('sub_r ow_id');

          var dealLength = myNewRow.childr en.length;
          for(i=0; i<dealLength; i++)
          {
          myNewRow.remove Child(myNewRow. lastChild);
          }
          var staticElem = document.create Element("TD");
          staticElem.widt h = 120;
          myNewRow.append Child(staticEle m);
          for(i=0;i<dealC ount;i++)
          {
          var myElem = document.create Element("TD");
          myElem.id = dealMenu[i].replace(' ','_');

          if(i==0)
          myElem.classNam e = "submenuhi" ;
          else
          myElem.classNam e = "submenu";

          myElem.width = 5*(dealMenu[i].length);

          if(dealJsp[i] != "")
          myElem.innerHTM L = "<a href="+dealJsp[i]+" target='mFrame' >"+dealMenu[i].replace(' ', '&nbsp;')+"</a>";
          else
          {
          myElem.onClick = 'productDrop(); '; myElem.innerHTM L = dealMenu[i];
          }
          alert(myElem.on Click);

          myNewRow.append Child(myElem);
          }
          myTable.childre n[0].appendChild(my NewRow);
          }
          function productDrop()
          {
          alert("Hi");
          }


          Thanks in advance,
          Srinivasan r.

          Comment

          • rsrinivasan
            New Member
            • Mar 2007
            • 221

            #6
            Hi,
            I cant send full code. Because it is our client code. So i sent only where i have the problem.

            Thanks,
            Srinivasan r.

            Comment

            • dmjpro
              Top Contributor
              • Jan 2007
              • 2476

              #7
              now the picture is more clearer than before ......

              actually myElem.onClick = 'productDrop(); ' this line does not work.....right! !!!!!!!!!!!!!!! !!

              actually myElem.onlCick takes no string assignment ... actually it takes the function_refere nece.

              i think u got my point.
              try urself ... if anything wrong then we r here.
              best of luck.

              kind regards.
              dmjpro.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                onClick should be onclick (lowercase "c").

                Comment

                • rsrinivasan
                  New Member
                  • Mar 2007
                  • 221

                  #9
                  Originally posted by dmjpro
                  now the picture is more clearer than before ......

                  actually myElem.onClick = 'productDrop(); ' this line does not work.....right! !!!!!!!!!!!!!!! !!

                  actually myElem.onlCick takes no string assignment ... actually it takes the function_refere nece.

                  i think u got my point.
                  try urself ... if anything wrong then we r here.
                  best of luck.

                  kind regards.
                  dmjpro.

                  Hi dmjpro,

                  I understand. But i do not know how to do it. I need exact code how to set the event. I try it lots of ways. but still it does not work. So plz if possible sent it immediately.
                  Thanks,

                  Comment

                  • dmjpro
                    Top Contributor
                    • Jan 2007
                    • 2476

                    #10
                    okkk.....

                    do the line myElem.onClick = 'productDrop(); ' as ....
                    myElem.onClick = productDrop();

                    i think this ll work..... if not then come again i m here.

                    kind regards.
                    dmjpro.

                    Comment

                    • rsrinivasan
                      New Member
                      • Mar 2007
                      • 221

                      #11
                      Originally posted by dmjpro
                      okkk.....

                      do the line myElem.onClick = 'productDrop(); ' as ....
                      myElem.onClick = productDrop();

                      i think this ll work..... if not then come again i m here.

                      kind regards.
                      dmjpro.
                      Hi,
                      Ya. It is called automatically when that line executed. But it will not fire when i click that TD.

                      Comment

                      • rsrinivasan
                        New Member
                        • Mar 2007
                        • 221

                        #12
                        Originally posted by dmjpro
                        okkk.....

                        do the line myElem.onClick = 'productDrop(); ' as ....
                        myElem.onClick = productDrop();

                        i think this ll work..... if not then come again i m here.

                        kind regards.
                        dmjpro.
                        Hi dmjpro,

                        Your code is working. But the event did not fire when i click the TD. Im in urgent situation. When i click, it did not respond anything.

                        Thanks,
                        Srinivasn r.

                        Comment

                        • dmjpro
                          Top Contributor
                          • Jan 2007
                          • 2476

                          #13
                          Originally posted by rsrinivasan
                          Hi dmjpro,

                          Your code is working. But the event did not fire when i click the TD. Im in urgent situation. When i click, it did not respond anything.

                          Thanks,
                          Srinivasn r.

                          then do one thing .... myElem.onClick = function(){aler t('Helooo.....Y ahoooooo')};
                          do one more thing ....myElem.onClick .......check the case sensivity for onClick

                          best of luck ...
                          plz give me feed back.
                          i m online.

                          kind regards.
                          dmjpro.

                          Comment

                          • rsrinivasan
                            New Member
                            • Mar 2007
                            • 221

                            #14
                            Originally posted by dmjpro
                            then do one thing .... myElem.onClick = function(){aler t('Helooo.....Y ahoooooo')};
                            do one more thing ....myElem.onClick .......check the case sensivity for onClick

                            best of luck ...
                            plz give me feed back.
                            i m online.

                            kind regards.
                            dmjpro.
                            Hi,
                            I try it. I replaced my code with ur code. But it did not work. what to do?

                            Code:
                            	myElem.onClick = function ff(){alert('Helooo.....Yahoooooo');}
                            Thanks,
                            Srinivas r.

                            Comment

                            • dmjpro
                              Top Contributor
                              • Jan 2007
                              • 2476

                              #15
                              Originally posted by rsrinivasan
                              Hi,
                              I try it. I replaced my code with ur code. But it did not work. what to do?

                              Code:
                              	myElem.onClick = function ff(){alert('Helooo.....Yahoooooo');}
                              Thanks,
                              Srinivas r.

                              hello ... i told u to write ..... anonymous function .....

                              u should write function() only instead of .... funciton ff() ... understood..
                              best of luck.

                              kind regards.
                              dmjpro.

                              Comment

                              Working...