Creating button dynamically not working in firefox..please help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ShutterMan

    Creating button dynamically not working in firefox..please help

    I have a function that creates input buttons dynamically...

    function $NEW_BUTTON(id, content, parentId, cssclass, onclick)
    {
    var ctrl = document.create Element("input" );
    ctrl.id = id;
    ctrl.setAttribu te("name", id);
    ctrl.setAttribu te("value", content);
    ctrl.setAttribu te("class", cssclass);
    ctrl.setAttribu te("type", "button");
    ctrl.setAttribu te("onclick", "javascript :" + onclick);
    $ID(parentId).a ppendChild(ctrl ); // equivalent to
    document.getEle mentById()
    }

    In both IE7 and FF3, the buttons are created. But in Firefox, the
    value of the button is always "undefined" . (In IE its correct). Any
    ideas?

    Thanks
  • GTalbot

    #2
    Re: Creating button dynamically not working in firefox..please help

    On Jul 20, 12:23 am, ShutterMan <scott.hut...@g mail.comwrote:
    I have a function that creates input buttons dynamically...
    >
        function $NEW_BUTTON(id, content, parentId, cssclass, onclick)
            {
            var ctrl = document.create Element("input" );
            ctrl.id = id;
            ctrl.setAttribu te("name", id);
            ctrl.setAttribu te("value", content);
            ctrl.setAttribu te("class", cssclass);
            ctrl.setAttribu te("type", "button");
            ctrl.setAttribu te("onclick", "javascript :" + onclick);
    There is no need for the "javascript :" to be appended. Anyway, I'm not
    sure this way of defining an onclick event handler can work.
            $ID(parentId).a ppendChild(ctrl );   // equivalent to
    document.getEle mentById()
        }
    >
    In both IE7 and FF3, the buttons are created.  But in Firefox, the
    value of the button is always "undefined" .  (In IE its correct).  Any
    ideas?
    >
    Thanks
    Can you post an URL?

    Regards, Gérard

    Comment

    • ShutterMan

      #3
      Re: Creating button dynamically not working in firefox..please help

      The button event handler isnt my issue at the moment..its that the
      text on the button is "undefined" in FF3, but whatever its supposed to
      be under IE7 (correct behavior).

      (Back to the handler question tho...IE7 DOESNT perform the function,
      where FF3 does...go figure..)


      On Jul 20, 1:10 am, GTalbot <newsgr...@gtal bot.orgwrote:
      On Jul 20, 12:23 am, ShutterMan <scott.hut...@g mail.comwrote:
      >
      I have a function that creates input buttons dynamically...
      >
          function $NEW_BUTTON(id, content, parentId, cssclass, onclick)
              {
              var ctrl = document.create Element("input" );
              ctrl.id = id;
              ctrl.setAttribu te("name", id);
              ctrl.setAttribu te("value", content);
              ctrl.setAttribu te("class", cssclass);
              ctrl.setAttribu te("type", "button");
              ctrl.setAttribu te("onclick", "javascript :" + onclick);
      >
      There is no need for the "javascript :" to be appended. Anyway, I'm not
      sure this way of defining an onclick event handler can work.
      >
              $ID(parentId).a ppendChild(ctrl );   // equivalent to
      document.getEle mentById()
          }
      >
      In both IE7 and FF3, the buttons are created.  But in Firefox, the
      value of the button is always "undefined" .  (In IE its correct).  Any
      ideas?
      >
      Thanks
      >
      Can you post an URL?
      >
      Regards, Gérard

      Comment

      • Adam C.

        #4
        Re: Creating button dynamically not working in firefox..please help

        On Jul 20, 1:18 am, ShutterMan <scott.hut...@g mail.comwrote:
        The button event handler isnt my issue at the moment..its that the
        text on the button is "undefined" in FF3, but whatever its supposed to
        be under IE7 (correct behavior).
        >
        (Back to the handler question tho...IE7 DOESNT perform the function,
        where FF3 does...go figure..)
        >
        On Jul 20, 1:10 am, GTalbot <newsgr...@gtal bot.orgwrote:
        >
        On Jul 20, 12:23 am, ShutterMan <scott.hut...@g mail.comwrote:
        >
        I have a function that creates input buttons dynamically...
        >
            function $NEW_BUTTON(id, content, parentId, cssclass, onclick)
                {
                var ctrl = document.create Element("input" );
                ctrl.id = id;
                ctrl.setAttribu te("name", id);
                ctrl.setAttribu te("value", content);
                ctrl.setAttribu te("class", cssclass);
                ctrl.setAttribu te("type", "button");
                ctrl.setAttribu te("onclick", "javascript :" + onclick);
        >
        There is no need for the "javascript :" to be appended. Anyway, I'm not
        sure this way of defining an onclick event handler can work.
        >
                $ID(parentId).a ppendChild(ctrl );   // equivalent to
        document.getEle mentById()
            }
        >
        In both IE7 and FF3, the buttons are created.  But in Firefox, the
        value of the button is always "undefined" .  (In IE its correct).  Any
        ideas?
        >
        Thanks
        >
        Can you post an URL?
        >
        Regards, Gérard
        >
        >
        Not sure what $ID is (I'm assuming it resolves to
        document.getEle mentById), but when I open up a JavaScript shell and
        run

        var aDiv = document.getEle mentById("divId "); // for a page with a div
        with ID "divId"
        var ctrl = document.create Element("input" );
        ctrl.id="xyz"
        ctrl.setAttribu te("name", "xyz")
        ctrl.setAttribu te("value", "someValue" )
        ctrl.setAttribu te("type", "button")
        aDiv.appendChil d(ctrl)

        it works just fine in FF3 for me... a button labelled "someValue"
        shows up inside aDiv.

        Comment

        • ShutterMan

          #5
          Re: Creating button dynamically not working in firefox..please help

          I figured it out - and thank you very much for looking at it... the
          code is ok.. the calling routine is:

          $NEW_BUTTON(id, tablesList[t].text, "div1", "", "somefunction() ;");

          Firefox doesnt like ".text"...i t apparently prefers ".textConte nt".
          All is well after that. I don't understand why the FF developers wont
          make concessions for these kinds of things, for compatibility sake.
          Standards are great and all, but at the cost of driving people mad?
          They could have easily implemented a ".text". :/ I could say the same
          for Microsoft, but we all know they wont adhere to standards. Oh
          well.. again, thanks for looking at it, much appreciated.


          On Jul 20, 2:00 am, "Adam C." <adam...@gmail. comwrote:
          On Jul 20, 1:18 am, ShutterMan <scott.hut...@g mail.comwrote:
          >
          >
          >
          The button event handler isnt my issue at the moment..its that the
          text on the button is "undefined" in FF3, but whatever its supposed to
          be under IE7 (correct behavior).
          >
          (Back to the handler question tho...IE7 DOESNT perform the function,
          where FF3 does...go figure..)
          >
          On Jul 20, 1:10 am, GTalbot <newsgr...@gtal bot.orgwrote:
          >
          On Jul 20, 12:23 am, ShutterMan <scott.hut...@g mail.comwrote:
          >
          I have a function that creates input buttons dynamically...
          >
              function $NEW_BUTTON(id, content, parentId, cssclass, onclick)
                  {
                  var ctrl = document.create Element("input" );
                  ctrl.id = id;
                  ctrl.setAttribu te("name", id);
                  ctrl.setAttribu te("value", content);
                  ctrl.setAttribu te("class", cssclass);
                  ctrl.setAttribu te("type", "button");
                  ctrl.setAttribu te("onclick", "javascript :" + onclick);
          >
          There is no need for the "javascript :" to be appended. Anyway, I'm not
          sure this way of defining an onclick event handler can work.
          >
                  $ID(parentId).a ppendChild(ctrl );   // equivalent to
          document.getEle mentById()
              }
          >
          In both IE7 and FF3, the buttons are created.  But in Firefox, the
          value of the button is always "undefined" .  (In IE its correct).  Any
          ideas?
          >
          Thanks
          >
          Can you post an URL?
          >
          Regards, Gérard
          >
          Not sure what $ID is (I'm assuming it resolves to
          document.getEle mentById), but when I open up a JavaScript shell and
          run
          >
          var aDiv = document.getEle mentById("divId "); // for a page with a div
          with ID "divId"
          var ctrl = document.create Element("input" );
          ctrl.id="xyz"
          ctrl.setAttribu te("name", "xyz")
          ctrl.setAttribu te("value", "someValue" )
          ctrl.setAttribu te("type", "button")
          aDiv.appendChil d(ctrl)
          >
          it works just fine in FF3 for me... a button labelled "someValue"
          shows up inside aDiv.

          Comment

          Working...