Problem with calling a function within a newly created element

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas 'PointedEars' Lahn

    #16
    Re: Problem with calling a function within a newly created element

    Joost Diepenmaat wrote:
    DL <tatata9999@gma il.comwrites:
    >ok, thanks, I think now I know what's going on. The 'qType'+i element
    >is a SELECT element with three options with values of ('YN' | 'CK' |
    >'RD'). Probaly the syntax of
    >document.getEl ementById(qt).v alue // qt being a var here
    >isn't correct, yes? If so, how do we deal with it?
    >
    You're missing that select elements don't have a value; the options
    have.
    Not quite true.



    However, there is a catch with that in IE. I think I have posted an
    explanation/test case before, but I can't seem to find it.


    PointedEars
    --
    var bugRiddenCrashP ronePieceOfJunk = (
    navigator.userA gent.indexOf('M SIE 5') != -1
    && navigator.userA gent.indexOf('M ac') != -1
    ) // Plone, register_functi on.js:16

    Comment

    • DL

      #17
      Re: Problem with calling a function within a newly created element

      On May 19, 6:22 pm, Joost Diepenmaat <jo...@zeekat.n lwrote:
      DL <tatata9...@gma il.comwrites:
      ok, thanks, I think now I know what's going on.  The 'qType'+i element
      is a SELECT element with three options with values of ('YN' | 'CK' |
      'RD').  Probaly the syntax of
      document.getEle mentById(qt).va lue // qt being a var here
      isn't correct, yes?  If so, how do we deal with it?
      >
      You're missing that select elements don't have a value; the options
      have.
      >
      use something like this:
      >
      // get the <selectelemen t
      var selectelement = document.getEle mentById(qt);
      // now get the value of the selected <optionin that element
      // assuming there's only one
      var value = selectelement.o ptions[selectelement.s electedIndex].value
      >
      --
      Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/
      Thanks. But I ran into a problem.

      var qt = 'qType'+i;
      alert(qt);
      // so far so good, it generates a valid value of the SELECT element's
      id;

      var selectelement = document.getEle mentById(qt);
      alert(selectele ment);
      // not good, it generates null value, hence, next step also failed.

      Could the "pointed ear something" mess up my browser (his/her
      javascript expertise is at a level to do something like that)?



      Comment

      • Joost Diepenmaat

        #18
        Re: Problem with calling a function within a newly created element

        Thomas 'PointedEars' Lahn <PointedEars@we b.dewrites:
        Joost Diepenmaat wrote:
        >DL <tatata9999@gma il.comwrites:
        >>ok, thanks, I think now I know what's going on. The 'qType'+i element
        >>is a SELECT element with three options with values of ('YN' | 'CK' |
        >>'RD'). Probaly the syntax of
        >>document.getE lementById(qt). value // qt being a var here
        >>isn't correct, yes? If so, how do we deal with it?
        >>
        >You're missing that select elements don't have a value; the options
        >have.
        >
        Not quite true.
        >

        >
        However, there is a catch with that in IE. I think I have posted an
        explanation/test case before, but I can't seem to find it.
        IIRC it didn't work reliably whenever it was that I fully tested it,
        and it still doesn't work reliably now, while the selectedIndex has
        worked for ages and continuous to work today. I'm also way too lazy to
        test it again.

        I'm probably overly cautious, but I don't expect anything after DOM-1
        to work flawlessly in popular browsers.

        --
        Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

        Comment

        • Joost Diepenmaat

          #19
          Re: Problem with calling a function within a newly created element

          DL <tatata9999@gma il.comwrites:
          Thanks. But I ran into a problem.
          >
          var qt = 'qType'+i;
          alert(qt);
          // so far so good, it generates a valid value of the SELECT element's
          id;
          >
          var selectelement = document.getEle mentById(qt);
          alert(selectele ment);
          // not good, it generates null value, hence, next step also failed.
          >
          Could the "pointed ear something" mess up my browser (his/her
          javascript expertise is at a level to do something like that)?
          Are you sure this is what's happening? At the risk of repeating
          something someone already mentioned, the best practical way to check
          is to use firefox with the firebug extension to check the _actual_ DOM
          structure at the time of the execution of the code. your explanation
          seems to indicate that there _isn't_ an element with the ID you
          expect.

          --
          Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

          Comment

          • DL

            #20
            Re: Problem with calling a function within a newly created element

            Thanks.  But I ran into a problem.
            >
            var qt = 'qType'+i;
                alert(qt);
            // so far so good, it generates a valid value of the SELECT element's
            id;
            >
            var selectelement = document.getEle mentById(qt);
            alert(selectele ment);
            // not good, it generates null value, hence, next step also failed.
            >
            Could the "pointed ear something" mess up my browser (his/her
            javascript expertise is at a level to do something like that)?
            >
            Are you sure this is what's happening? At the risk of repeating
            something someone already mentioned, the best practical way to check
            is to use firefox with the firebug extension to check the _actual_ DOM
            structure at the time of the execution of the code. your explanation
            seems to indicate that there _isn't_ an element with the ID you
            expect.
            >
            --
            Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/
            Ahe. I know where the problem is... maybe...
            Here's the code for this portion,
            <select id="qType"+i name="qType"+i onchange="doChe ckbox('+i
            +','+nextrow+') "><option value="YN" selected>Yes/No<option
            value="CK">Chec kbox<option value="RD">Radi o</select>

            // silly me, the form wasn't sent, how to expect an element of it?
            // now, I only need this SELECT element for the doCheckbox function,
            could I re-write the above code to
            <select id="qType"+i name="qType"+i
            onchange="doChe ckbox(this.valu e,'+i+','+nextr ow+')"><option value="YN"
            selected>Yes/No<option value="CK">Chec kbox<option value="RD">Radi o</
            select>
            to pass the SELECT element's value along?

            My test indicates no. Then how?

            Unfortunately the other viable alternative of using Firefox with
            Firebug isn't available at this point. A company called Aka???
            embeded encrypted code (probably to track what's going on with my FF
            usage), but that's none of their f??? business and I cursed them
            publicly, and they are security experts, now, my FF is hardly working,
            let alone the powerful Firebug debugging feature). Trying the lame re-
            installation to no avail...

            Thanks.




            Comment

            • DL

              #21
              Re: Problem with calling a function within a newly created element

              <select id="qType"+i name="qType"+i  onchange="doChe ckbox('+i
              +','+nextrow+') "><option value="YN" selected>Yes/No<option
              value="CK">Chec kbox<option value="RD">Radi o</select>
              >
              // silly me, the form wasn't sent, how to expect an element of it?
              // now, I only need this SELECT element for the doCheckbox function,
              could I re-write the above code to
              <select id="qType"+i name="qType"+i
              onchange="doChe ckbox(this.valu e,'+i+','+nextr ow+')"><option value="YN"
              selected>Yes/No<option value="CK">Chec kbox<option value="RD">Radi o</
              select>
              to pass the SELECT element's value along?
              ok, the most desirable thing is to either send or somehow be able to
              retrieve the newly populated value of the SELECT element from the
              doCheckbox function. And if this option is a no go, send the whole
              form? onchange="doChe ckbox(form.subm it(),'+i+','+ne xtrow+')"//
              won't work
              // it's about 10:24pm here, am I getting real slow?

              Thanks.

              Comment

              • Thomas 'PointedEars' Lahn

                #22
                Re: Problem with calling a function within a newly created element

                DL wrote:
                ^^^^^^^^^
                This is an attribution line. Again, please include one next time.
                >>Thanks. But I ran into a problem.
                >>>
                >>var qt = 'qType'+i; alert(qt);
                >>// so far so good, it generates a valid value of the SELECT element's
                >>id;
                As you have been told before, code should be posted so that it has good
                chances to remain executable when copypasted, after being line-broken.
                Therefore, single-line comments should appear *before* the code they
                describe, and if they are long enough, multi-line comments /* ... */
                should be used instead.
                >>var selectelement = document.getEle mentById(qt);
                >>alert(selecte lement);
                >>// not good, it generates null value, hence, next step also failed.
                >>>
                >>Could the "pointed ear something" mess up my
                >>browser (his/her javascript expertise is at a level to do something
                >>like that)?
                So now you're blaming the result of your stupidity on the expertise of
                others? (It's _he_ BTW, Thomas isn't a name you would give to a girl,
                now is it?) :-(
                >[...] your explanation seems to indicate that there _isn't_ an element
                >with the ID you expect.
                >
                Ahe. I know where the problem is... maybe... Here's the code for this
                portion,
                >
                <select id="qType"+i name="qType"+i onchange="doChe ckbox('+i
                If an HTML parser were to parse this, it would read either

                <select id="qType" name="qType" onchange="doChe ckbox('+i

                or

                <select id="qType&quot; +i" name="qType&quo t;+1" onchange="doChe ckbox('+i

                In the first case the element would not have the ID that you expect it to
                have; in the second case the result is invalid as IDs must not contain the
                `+' character. But see below.
                +','+nextrow+') "><option value="YN" selected>Yes/No<option
                value="CK">Chec kbox<option value="RD">Radi o</select>
                >
                // silly me, the form wasn't sent, how to expect an element of it? //
                now, I only need this SELECT element for the doCheckbox function, could I
                re-write the above code to <select id="qType"+i name="qType"+i
                onchange="doChe ckbox(this.valu e,'+i+','+nextr ow+')"><option value="YN"
                selected>Yes/No<option value="CK">Chec kbox<option value="RD">Radi o</
                selectto pass the SELECT element's value along?
                >
                My test indicates no. Then how?
                You have posted invalid HTML. Assuming in your favor that the code is a
                string value that is the argument of document.write( ) or something like that
                instead, you have forgotten to escape `</' (End TAG Open delimiter) as `<\/'
                within that string.
                Unfortunately the other viable alternative of using Firefox with Firebug
                isn't available at this point. A company called Aka??? embeded encrypted
                code (probably to track what's going on with my FF usage),
                What the heck are you talking about? Do you want to be a serious software
                developer, or do you want to be a script kiddie?
                but that's none of their f??? business and I cursed them publicly, and
                they are security experts, now, my FF is hardly working, let alone the
                powerful Firebug debugging feature). Trying the lame re- installation to
                no avail...
                Maybe you should someone let do the job who knows what they are doing.


                PointedEars
                --
                Anyone who slaps a 'this page is best viewed with Browser X' label on
                a Web page appears to be yearning for the bad old days, before the Web,
                when you had very little chance of reading a document written on another
                computer, another word processor, or another network. -- Tim Berners-Lee

                Comment

                • DL

                  #23
                  Re: Problem with calling a function within a newly created element

                  Unfortunately the other viable alternative of using Firefox with Firebug
                  isn't available at this point. A company called Aka??? embeded encrypted
                  code (probably to track what's going on with my FF usage),
                  What the heck are you talking about? Do you want to be a serious
                  software
                  developer, or do you want to be a script kiddie?
                  but that's none of their f??? business and I cursed them publicly, and
                  they are security experts, now, my FF is hardly working, let alone the
                  powerful Firebug debugging feature).  Trying the lame re- installationto
                  no avail...
                  >
                  Maybe you should someone let do the job who knows what they are doing.
                  >
                  PointedEars
                  --
                  Fk off, you m fker for the last time on your m's grave! I've asked
                  you to do so repeatedly in private but you did not listen, so, I have
                  to publicly! Once again, you m fker, fk off!!!!

                  Comment

                  Working...