two dropdown menus

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

    #1

    two dropdown menus

    Can anybody help me? I am trying to create two drop down menus, where the
    results of the second one vary depending on what was selected in the first
    one. I am using MS Script Editor in MS Front Page to do this.

    In my first menu, I want "English" "German" and "Russian."

    Now if "English" is picked, I want "French" "German" and "Spanish" to
    appear.
    If "German" is picked in the first menu, I want "English" to appear"
    If Russian is picked in the first menu, I want "Dutch" to appear.

    Any advice? I ain't clued up that much on Javascript!

    Thanks all


  • Kien

    #2
    Re: two dropdown menus

    Continental Translations wrote:[color=blue]
    > Can anybody help me? I am trying to create two drop down menus, where the
    > results of the second one vary depending on what was selected in the first
    > one. I am using MS Script Editor in MS Front Page to do this.
    >
    > In my first menu, I want "English" "German" and "Russian."
    >
    > Now if "English" is picked, I want "French" "German" and "Spanish" to
    > appear.
    > If "German" is picked in the first menu, I want "English" to appear"
    > If Russian is picked in the first menu, I want "Dutch" to appear.
    >
    > Any advice? I ain't clued up that much on Javascript!
    >
    > Thanks all
    >
    >[/color]
    Hi,
    Go here



    HTH Kien

    Comment

    • kaeli

      #3
      Re: two dropdown menus

      In article <ca9f5u$apg$1@h ercules.btinter net.com>,
      neilgreenough@b topenworld.com enlightened us with...

      [color=blue]
      > I am using MS Script Editor in MS Front Page to do this.[/color]

      I'm sorry.
      What did you do to deserve that?
      [color=blue]
      >
      > In my first menu, I want "English" "German" and "Russian."
      >
      > Now if "English" is picked, I want "French" "German" and "Spanish" to
      > appear.
      > If "German" is picked in the first menu, I want "English" to appear"
      > If Russian is picked in the first menu, I want "Dutch" to appear.
      >[/color]

      The following works in IE6 and NN7. I didn't check other browsers. Watch
      for word-wrap.

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
      "http://www.w3.org/TR/REC-html40/loose.dtd">
      <html>
      <head>
      <title> Dynamic select boxes </title>
      <script type="text/javascript" language="javas cript">
      var firstChoices = new Array(
      "English",
      "German",
      "Russian"
      );

      var secondChoices = new Array();
      secondChoices["English"] = new Array(
      "French",
      "German",
      "Spanish"
      );
      secondChoices["German"] = new Array(
      "English"
      );
      secondChoices["Russian"] = new Array(
      "Dutch"
      );

      function setUp()
      {
      // get form element
      var f = document.getEle mentById("f1");

      // make first select element
      var s1 = document.create Element("select ");
      s1.setAttribute ("name","s1" );
      s1.setAttribute ("id","s1");
      f.appendChild(s 1);

      // fill in first select element
      var L = firstChoices.le ngth;
      var i;
      var o;
      o = document.create Element("option ");
      o.setAttribute( "name","o") ;
      o.setAttribute( "id","o");
      o.setAttribute( "value","0" );
      o.appendChild(d ocument.createT extNode("--- Choose One ---"));
      s1.appendChild( o);
      for (i=0; i<L; i++)
      {
      o = document.create Element("option ");
      o.setAttribute( "name","o"+ i);
      o.setAttribute( "id","o"+i) ;
      o.setAttribute( "value",firstCh oices[i]);
      o.appendChild(d ocument.createT extNode(firstCh oices[i]));
      s1.appendChild( o);
      }
      // attach onchange event to select
      if (s1.attachEvent )
      {
      s1.attachEvent( "onchange",edit Options);
      }
      else if (s1.addEventLis tener)
      {
      s1.addEventList ener("change",e ditOptions,fals e);
      }
      }

      function editOptions()
      {
      // make second select depending on value of first
      // if it's already there, remove it and re-create

      // get form element
      var f = document.getEle mentById("f1");

      if (document.getEl ementById("s2") )
      f.removeChild(d ocument.getElem entById("s2"));


      // get the value of the first select
      var val = f.elements["s1"].options[f.elements
      ["s1"].selectedIndex].value;

      // make second select element
      var s2 = document.create Element("select ");
      s2.setAttribute ("name","s2" );
      s2.setAttribute ("id","s2");
      f.appendChild(s 2);

      // fill in second select element
      var L = secondChoices[val].length;
      var i;
      var o;
      o = document.create Element("option ");
      o.setAttribute( "name","o") ;
      o.setAttribute( "id","o");
      o.setAttribute( "value","0" );
      o.appendChild(d ocument.createT extNode("--- Choose One ---"));
      s2.appendChild( o);
      for (i=0; i<L; i++)
      {
      o = document.create Element("option ");
      o.setAttribute( "name","o"+ i);
      o.setAttribute( "id","o"+i) ;
      o.setAttribute( "value",secondC hoices[val][i]);
      o.appendChild(d ocument.createT extNode(secondC hoices[val][i]));
      s2.appendChild( o);
      }
      }
      </script>
      </head>

      <body onLoad="setUp() ">
      <form name="f1" id="f1" action="">
      </form>
      </body>
      </html>

      --
      --
      ~kaeli~
      Time flies like an arrow. Fruit flies like a banana.



      Comment

      • Matt Kruse

        #4
        Re: two dropdown menus

        Continental Translations wrote:[color=blue]
        > Can anybody help me? I am trying to create two drop down menus, where
        > the results of the second one vary depending on what was selected in
        > the first one.[/color]

        This is a FAQ, and should probaly be addressed in the FAQ!

        There are a number of solutions available. Some are specific to the data and
        screen in question, others are general solutions which can be reused on any
        page where dynamic dropdown menus are needed. my solution falls into the
        latter, and can be found at


        Be aware that these client-side javascript solutions will fail for browsers
        that do not support javascript, and depending on your requirements, you may
        want to include a server-side solution which duplicates the same behavior.

        --
        Matt Kruse
        Javascript Toolbox: http://www.JavascriptToolbox.com/


        Comment

        • Richard Cornford

          #5
          Re: two dropdown menus

          Matt Kruse wrote:[color=blue]
          > Continental Translations wrote:[color=green]
          >> Can anybody help me? I am trying to create two drop down menus, where
          >> the results of the second one vary depending on what was selected in
          >> the first one.[/color]
          >
          > This is a FAQ, and should probaly be addressed in the FAQ![/color]
          <snip>

          It is certainly a regularly asked question, I don't know that it is
          frequently asked in the sense that most other FAQ questions are as it
          seems to come in spates with a couple of months in-between. But maybe it
          is (though you will have to follow FAQ request procedure if you want it
          considered for the next review).

          But what would the FAQ say on the subject: "Don't design this
          requirement into a project as it cannot be satisfactorily implemented."?
          There isn't an implementation that I would recommend, I have only seen
          three that even attempt to address the degradation issue and none of
          them are that usable in their degraded state (Lasse Reichstein Nielsen's
          being about the best, but it sacrifices some (old) browser
          compatibility).

          Richard.


          Comment

          • Matt Kruse

            #6
            Re: two dropdown menus

            Richard Cornford wrote:[color=blue]
            > (though you will have to follow FAQ request procedure if you
            > want it considered for the next review).[/color]

            Or maybe I'll just create a simple HTML page addressing the issue.
            A lot of the same responses are posted to this group, not just for this
            question, but for many others. It would be helpful to summarize the
            responses into a single HTML page that users could be directed to. Even if
            it's not in the official FAQ.
            [color=blue]
            > But what would the FAQ say on the subject: "Don't design this
            > requirement into a project as it cannot be satisfactorily
            > implemented."?[/color]

            No, it would point out a number of resources which solve the problem, both
            with simple examples (storing options in arrays and simply creating new
            Option objects) and complex solutions (like my library and others).

            It would also point out that there are potential problems with relying on
            this functionality, explain why, and gives examples of situations where this
            must be taken into consideration and situations where it's not a concern.
            [color=blue]
            > There isn't an implementation that I would recommend[/color]

            That's because you try to fit everything into a box that you are comfortable
            with :)
            [color=blue]
            > I have only seen three that even attempt to address the degradation
            > issue[/color]

            Of course, the degradation issues doesn't always need to be addressed. If a
            summary of the issue pointed out that for environments where browsers are
            fixed, or javascript is required, or degrading gracefully is not important,
            then the user could simply select which pre-existing solution fitted their
            needs the best.
            [color=blue]
            > and none of them are that usable in their degraded state (Lasse
            > Reichstein Nielsen's being about the best, but it sacrifices some
            > (old) browser compatibility).[/color]

            When I get time to play with it, I'll build an example that degrades nicely
            for you, using my library.
            In short, it works like this:
            ------------------------------------------------------------------------
            <select name="first" onchange="if (browser has enough capabilities) { call
            dynamic population code }">
            <noscript>
            <submit><!-- Go back to server to re-draw page with second option-->
            </noscript>
            <script>
            if (browser has enough capabilities) {
            document.write( other select elements)
            }
            else {
            document.write( submit button)
            }
            </script>
            ------------------------------------------------------------------------

            Do you see any problems with such a solution?

            --
            Matt Kruse
            Javascript Toolbox: http://www.JavascriptToolbox.com/


            Comment

            • Richard Cornford

              #7
              Re: two dropdown menus

              Matt Kruse wrote:[color=blue]
              > Richard Cornford wrote:[color=green]
              >> (though you will have to follow FAQ request procedure if you
              >> want it considered for the next review).[/color]
              >
              > Or maybe I'll just create a simple HTML page addressing the issue.
              > A lot of the same responses are posted to this group, not just for
              > this question, but for many others. It would be helpful to summarize
              > the responses into a single HTML page that users could be directed
              > to. Even if it's not in the official FAQ.[/color]

              You (and indeed anyone else who feels like it) are at liberty to create
              HTML pages for inclusion in the FAQ notes. Obviously the results would
              have to be subject to public review for accuracy, completeness and
              general suitability for inclusion (and subject to future editing if that
              was considered necessary as circumstances change).
              [color=blue][color=green]
              >> But what would the FAQ say on the subject: "Don't design this
              >> requirement into a project as it cannot be satisfactorily
              >> implemented."?[/color]
              >
              > No, it would point out a number of resources which solve the problem,[/color]

              If you could find such resources. But you define 'solution' as only
              relating to the mechanics of doing what can be done where it can be done
              with client-side scripting, while I think 'solution' includes the script
              design issues.
              [color=blue]
              > both with simple examples (storing options in arrays and simply
              > creating new Option objects) and complex solutions (like my library
              > and others).[/color]

              There is quite a lot of writing in that :)
              [color=blue]
              > It would also point out that there are potential problems with
              > relying on this functionality, explain why, and gives examples of
              > situations where this must be taken into consideration and situations
              > where it's not a concern.[/color]

              But are you in a position to give that information, even asses the
              criteria? It isn't a couple of weeks since you stated that you didn't
              think that the ADA applied to public commercial web sites in the US (and
              I don't really know if it does), but in a thread where the OP posted
              through a UK ISP it is the British DDA that is probably applicable.

              It is difficult to judge the scope of the DDA as currently there is none
              of the required legal precedents as the cases that have been brought to
              date have all been settled out of court (with the web site owners paying
              damages, but not admitting liability). And it will probably take the
              full appeals procedure to be applied (all the way to the European court)
              before anyone can be certain where accessibility is required from web
              sites. But the DDA has the potential (if enough judges eventually rule
              that way) to be as draconian as the Australian DDA, where I gather that
              every public web site is required to be accessible and so needlessly
              introducing javascript dependencies is actually likely to result in a
              fine for anyone (and a big fine for commercial enterprises). Making it
              an issue that Australian posters need to here about up front.

              And then there is the Internet/Intranet question. Over on alt.html at
              the moment there is a discussion started by an Australian developer who
              has used a javascript menu implementation in an Intranet project that
              inhibits the scaling of fonts (a common, but completely avoidable,
              feature of javascript menus). The problem is that an existing employee
              is 80% blind and cannot use the menu without scaling the fonts up (which
              the menu will not allow). The other Australian developers contributing
              to the thread are convinced their DDA does apply to that (and presumably
              other) Intranet project(s), at lest in part because it forbids an
              employer form discriminating against current and potential future
              employees on the grounds of disability. (The British DDA makes a
              similar requirement of employers, with some exceptions.)

              This seems to make determining the extent to which the introduction of a
              javascript dependency can be considered acceptable quite difficult to
              judge, with regional variations such that an Australian developer wants
              to avoid them, a British developer would be well advised to err on the
              side of caution (at least for the time being) and maybe US developers
              really don't have to think about it (beyond their personal morality).
              And then there is the rest of the world, where any country may have, or
              introduce, its own legislation on the subject.

              <snip>[color=blue]
              > When I get time to play with it, I'll build an example that degrades
              > nicely for you, using my library.
              > In short, it works like this:
              > ----------------------------------------------------------------------[/color]
              --[color=blue]
              > <select name="first" onchange="if (browser has enough capabilities) {
              > call dynamic population code }">
              > <noscript>
              > <submit><!-- Go back to server to re-draw page with second
              > option--> </noscript>
              > <script>
              > if (browser has enough capabilities) {
              > document.write( other select elements)
              > }
              > else {
              > document.write( submit button)
              > }
              > </script>
              > ----------------------------------------------------------------------[/color]
              --[color=blue]
              >
              > Do you see any problems with such a solution?[/color]

              NOSCRIPT is a block element so it cannot necessarily be inserted in any
              context without an impact on the resulting page flow.

              The second script element will probably not be in a position to properly
              test whether the browser is sufficiently dynamic to facilitate the
              client-side manipulation of the OPTIONs as that is only achievable by
              trying it and testing the results to see if it worked. Attempting that
              as the page loads will error, and even crash, some browser, from which
              there is no ability to recover and write the now needed submit button.

              This implementation would impose extra work on whoever was writing the
              server-side scripts as they not only have to populate your javascript
              data structures for the select list, but they also have to implement the
              server-side fall back (and ensure that the two interface styles make
              sense to the server-side code).

              Richard.


              Comment

              • Matt Kruse

                #8
                Re: two dropdown menus

                Richard Cornford wrote:[color=blue][color=green]
                >> No, it would point out a number of resources which solve the problem,[/color]
                > If you could find such resources. But you define 'solution' as only
                > relating to the mechanics of doing what can be done where it can be
                > done with client-side scripting, while I think 'solution' includes
                > the script design issues.[/color]

                You can't make everyone's decisions for them. If someone is looking for a
                technical solution, you provide them with a technical solution. It's up to
                them to decide if it fits. If they want consulting to know whether it's the
                best option, or if there are better ways to deliver content, then that's a
                different issue.

                When I go in to get a new muffler for my car, for example, I don't expect to
                have the salesman tell me why my car is a bad choice, and why I should be
                driving something else instead. That's outside the scope of the discussion.
                His job isn't to provide advice to me on whether or not I'm driving the
                right car. His job is to help me pick a muffler, make sure it works for my
                car, and put it on.

                Likewise, a provider of technical solutions should help pick the best
                solution, make sure it works, and provide implementation details. If the
                user's requirements are "this should work in all browsers anywhere" then
                that certainly changes the situation. If the user says "it only needs to
                work on IE6" then that may affect the solution selected.

                If you want to function as a consultant and tell people when various
                technologies should be used, and the good and bad of various design
                decisions, that's cool. There's a need for that. I'd rather focusing on
                providing technical solutions that can be implemented by people who have
                already decided that it's what they need. It's more fun. IMO.
                [color=blue][color=green]
                >> It would also point out that there are potential problems with
                >> relying on this functionality, explain why, and gives examples of
                >> situations where this must be taken into consideration and situations
                >> where it's not a concern.[/color]
                > But are you in a position to give that information, even asses the
                > criteria?[/color]

                Certainly.
                If your requirement is to support all browsers, even without javascript
                enabled, then you should do X.
                If only certain browsers are required to be supported, then you should do Y.
                If you require backwards-compatability, then you should do Z.

                It's up to the person implementing the site to determine what the
                requirements are. If they have to comply with some ADA or DDA rules, then
                they need to know that, and understand what restrictions that places on
                their choices. Then, armed with that knowledge, they can build their
                requirements and select the right tool.

                I'll never concern myself with what the ADA says or what the DDA says. I
                will simply say, "these are the limitations of this solution. If these
                aren't acceptable to you, then find a different solution."
                [color=blue]
                > And then there is the Internet/Intranet question. Over on alt.html at
                > the moment there is a discussion started by an Australian developer
                > who has used a javascript menu implementation in an Intranet project
                > that inhibits the scaling of fonts (a common, but completely
                > avoidable, feature of javascript menus).[/color]

                Then it's that web developer's fault for not understanding their true
                requirements, and finding a solution which fit them.
                It's certainly not the script author's fault for implementing something that
                doesn't fit someone else's requirements.
                [color=blue]
                > NOSCRIPT is a block element so it cannot necessarily be inserted in
                > any context without an impact on the resulting page flow.[/color]

                <style>
                noscript { display:inline; margin:0px; }
                </style>

                Even without css, so what?
                If a person has javascript disabled, they won't see as "pretty" of a page,
                but the functionality will still be there. That's what matters, right? The
                developer can decide how to design around such issues.
                [color=blue]
                > The second script element will probably not be in a position to
                > properly test whether the browser is sufficiently dynamic to
                > facilitate the client-side manipulation of the OPTIONs as that is
                > only achievable by trying it and testing the results to see if it
                > worked.[/color]

                Hmm.... if window.Option exists, and a call to it works, then an Option
                object can be created. In every browser that I know of, if I can create an
                Option object, I can add it to a select list. Except for Opera 5.? which has
                a bug. That could be checked as a special case with browser sniffing. By
                default, in case of any errors at all, the javascript mode could be turned
                off.

                Do you propose to _never_ add options to select lists? Because even
                attempting to do so and seeing if it works will fail in some browsers in
                some situations, in a way that cannot be trapped. You can't code for _every_
                situation. Buggy browsers should not be supported.
                [color=blue]
                > This implementation would impose extra work on whoever was writing the
                > server-side scripts as they not only have to populate your javascript
                > data structures for the select list, but they also have to implement
                > the server-side fall back (and ensure that the two interface styles
                > make sense to the server-side code).[/color]

                Now you're really reaching, Richard :)

                Sure, it may be more work, but your argument was that it's not possible -
                not that it was easy and quick.
                Lots of cool things are extra work. If a person wants this functionality on
                both server-side and client-side, then they can do the work.
                Besides, both client-side code and server-side code would surely work off
                the same back-end logic, so outputing the requirement script calls surely
                would not be as much work as you would make it seem.

                --
                Matt Kruse
                Javascript Toolbox: http://www.JavascriptToolbox.com/


                Comment

                • Richard Cornford

                  #9
                  Re: two dropdown menus

                  Matt Kruse wrote:[color=blue]
                  > Richard Cornford wrote:[color=green][color=darkred]
                  >>> No, it would point out a number of resources which solve the
                  >>> problem,[/color]
                  >> If you could find such resources. But you define 'solution' as only
                  >> relating to the mechanics of doing what can be done where it can be
                  >> done with client-side scripting, while I think 'solution' includes
                  >> the script design issues.[/color]
                  >
                  > You can't make everyone's decisions for them.[/color]

                  I don't even try to make peoples decisions for them. But I do try to
                  encourage the making of informed decisions.
                  [color=blue]
                  > If someone is looking for a technical solution,
                  > you provide them with a technical solution.[/color]

                  If someone is paying me for a technical solution then I do try to create
                  the best technical solution that I am capable of, otherwise I would not
                  be able to take any pride in my work.
                  [color=blue]
                  > It's up to them to decide if it fits.[/color]

                  No, I would have said that it was up to them to come up with a
                  specification first (though not necessarily on their own).
                  [color=blue]
                  > If they want consulting to know whether it's the best option,
                  > or if there are better ways to deliver content, then that's a
                  > different issue.[/color]

                  Getting opinions on the best way of doing anything is an inevitable
                  consequence of using Usenet. If people don't want that then they need to
                  employ developers directly.

                  But have you thought about how this notion sits with your suggestion
                  that the individuals that employ javascript on their web sites should
                  not be expected to have more than a rudimentary knowledge of javascript?
                  How can someone with little knowledge of javascript make an informed
                  decision about the relative quality and suitability of javascript
                  implementations for any given context unless someone who has that
                  knowledge tells them what needs to be considered?

                  <snip>[color=blue]
                  > His job is to help me pick
                  > a muffler, make sure it works for my car, and put it on.[/color]
                  ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ ^^^^^^^^^
                  See, you actually want a lot more than the abiity to demand something
                  and just have it handed over regardless. You want the people who have
                  technical skills to to bring them to the table if you don't have
                  them.
                  [color=blue]
                  > Likewise, a provider of technical solutions should
                  > help pick the best solution, make sure it works,
                  > and provide implementation details.[/color]

                  I don't have a problem with that in general, but helping to pick the
                  best solution certainly should include things like advising on the
                  appropriateness of the criteria.
                  [color=blue]
                  > If the user's requirements are "this should work in all
                  > browsers anywhere" then that certainly changes the situation.[/color]

                  There is a running theme in your posts where you describe the people who
                  employ your javascript as "users". Given what you write I can see how,
                  from your perspective, they are users; your users at least. But they are
                  not users they are developers, designers, web site owners, and
                  ultimately clients. The user is the person sitting in front of their
                  browsers looking at the resulting web site. Making life easy for the
                  clients you consider your users isn't necessarily doing any good for the
                  real users.

                  When you say that this "changes the situation" you are implying that a
                  web site should not be expected to be functional on the Internet by
                  default. I would have thought that would be the reverse of the normal
                  client's expectations. My starting point would be to assume that a
                  public web site was expected to operate to normal Internet
                  interoperabilit y standards by default and then examine the validity of
                  any reasoning that suggested detracting from that. It should be the
                  things that do introduce a dependency of some sort, such as data binding
                  or socket communication through applets or ActiveX that change the
                  situation.

                  But no client would specify every web browser anywhere, and no sane
                  developer would accept the requirement, because neither is capable of
                  being aware what every web browser anywhere means. There would be no way
                  to know if the result met that requirement and so no way of deciding if
                  and when the job was finished (for either party).

                  A specification of a list of browsers with which a commission will
                  function can be looked upon as a specification of test criteria that can
                  be used to determine that the delivered end result confirms with the
                  specification. But the Internet was designed around interoperabilit y and
                  normal authoring principles, the application of suitable standard and
                  appropriate design can deliver a result that works (and should be
                  expected to work, even if that could not be made a specified
                  requirement) with browsers outside of the test set.
                  [color=blue]
                  > If the user says "it only needs to work on IE6" then
                  > that may affect the solution selected.[/color]

                  When a specification says that something only needs to work on IE 6 it
                  means that it only needs to be demonstrated to be working on IE 6, it
                  doesn't mean that it must not work on any other browser, and it does not
                  mean that it only has to work on javascript enabled default
                  configurations of IE 6 either.

                  Anything that will cope with all configuration
                  permutations of IE 6 could be implemented in a way
                  that would work pretty much the same on all dynamic standards
                  compliant browsers (at minimum) for no additional effort in
                  script creation. Under those circumstances, and given a non-Intranet
                  application, it looks like the initial specification was not well
                  informed, or it was chosen for convenience in testing.
                  [color=blue]
                  > If you want to function as a consultant and tell people when
                  > various technologies should be used, and the good and bad of
                  > various design decisions, that's cool. There's a need for that.[/color]

                  There is a need for that.
                  [color=blue]
                  > I'd rather focusing on providing technical solutions that
                  > can be implemented by people who have already decided that it's
                  > what they need. It's more fun. IMO.[/color]

                  I could churn out javascript dependent half-ass hacks till the cows come
                  home, any fool could. But to implement a script such that it meets the
                  strictest design criteria, addresses and handles all of the issues,
                  exhibits planned behaviour in the face of every permutation of browser
                  environment and do so on a time scale equivalent to any less complete
                  'solution', that is a challenge. And for me a challenge is more fun.

                  Not to mention that you learn more from being challenged than from going
                  over the same ground time and again. Two years ago I was writing scripts
                  much like you write now, and I thought I know what I was doing, but at
                  least when I was introduced to the issues in browser scripting I was
                  willing to recognise them an learn to handle them. Your complacency is
                  going to mean that in two years time you are going to still be writing
                  scripts much as you do now, and continuing to contribute towards making
                  the Internet a worse place than it has to be.
                  [color=blue][color=green][color=darkred]
                  >>> It would also point out that there are potential problems with
                  >>> relying on this functionality, explain why, and gives examples of
                  >>> situations where this must be taken into consideration and
                  >>> situations where it's not a concern.[/color]
                  >> But are you in a position to give that information, even asses the
                  >> criteria?[/color]
                  >
                  > Certainly.
                  > If your requirement is to support all browsers, even without
                  > javascript enabled, then you should do X.
                  > If only certain browsers are required to be supported, then you
                  > should do Y. If you require backwards-compatability, then you should
                  > do Z.[/color]

                  And you accuse me of trying to fit everything into a box that I am
                  comfortable with. This is hardly a comprehensive list of web site design
                  requirements, but if X is normal internet authoring with
                  interoperabilit y as the goal it must also satisfy Y under most
                  circumstances and Z much of the time.
                  [color=blue]
                  > It's up to the person implementing the site to determine what the
                  > requirements are.[/color]

                  Who is the "person implementing the site"? The owner of the site, their
                  business managers, the project manager, the designer, the developers?
                  Aren't the requirements going to be hierarchical? Is a business manager
                  expected to comprehend the distinction between an unnecessary dependency
                  and an unavoidable one, or a designer the best person to be choosing a
                  menu implementation (rather than just deciding what it should look like
                  when implemented)? Shouldn't design be a collaborative process moving
                  through stages from the general to the specific, with the input form the
                  top of the decision making hierarchy maybe diminishing and the input
                  from the bottom end increasing as the process moves toward completion?

                  <snip>[color=blue][color=green]
                  >> And then there is the Internet/Intranet question. Over on alt.html at
                  >> the moment there is a discussion started by an Australian developer
                  >> who has used a javascript menu implementation in an Intranet project
                  >> that inhibits the scaling of fonts (a common, but completely
                  >> avoidable, feature of javascript menus).[/color]
                  >
                  > Then it's that web developer's fault for not understanding their
                  > true requirements, and finding a solution which fit them.[/color]

                  The web developer certainly could have done better in that area. But
                  there is your problem again, web developers don't necessarily have the
                  skills to judge every aspect of what they are asked to do. They may know
                  everything that can be known about their own specialisation and next to
                  nothing about another. This individual seemed mostly concerned with
                  server-side scripting, but that wouldn't equip him to judge a javascript
                  implementation or comprehend the impact on accessibility that followed
                  from the HTML/CSS employed by that script.
                  [color=blue]
                  > It's certainly not the script author's fault for implementing
                  > something that doesn't fit someone else's requirements.[/color]

                  But the script author was utterly misguided in creating a script for use
                  in a browser environment that detracted from the usability of that
                  browser for no apparent reason. Though in practice I have no doubt that
                  the actual reason was an ignorance of how to do any better.

                  Browsers have characteristics and scripts for use in browsers should
                  take those into account. Fonts can be scaled to suite the user, that
                  isn't a secret it is right there in the menus for anyone to see.

                  Then again the script author may have known that the menu could be
                  implemented flexibly but didn't care to learn to do any better and just
                  offered the script up on a take it or leave it basis, and the developer,
                  not knowing what criteria to apply to the choice of menu script, used it
                  because it was there.

                  That happens a lot, people who don't know any better lumber themselves
                  with problems by choosing inappropriate scripts because those scripts
                  are easy to find. Not knowing what they have done until a problem
                  manifests itself and then not knowing what to do about it. Assuming the
                  consequence of the use of a poor script has an observable manifestation,
                  which might not be the case when, say, a needless javascript dependency
                  is reducing turnover for a small business site as there will be not
                  turnover figures without the dependency against which a comparison could
                  be made.

                  <snip>[color=blue]
                  > Hmm.... if window.Option exists, and a call to it works, then an
                  > Option object can be created. In every browser that I know of, if I
                  > can create an Option object, I can add it to a select list. Except
                  > for Opera 5.? which has a bug. That could be checked as a special
                  > case with browser sniffing. By default, in case of any errors at all,
                  > the javascript mode could be turned off.
                  >
                  > Do you propose to _never_ add options to select lists? Because even
                  > attempting to do so and seeing if it works will fail in some browsers
                  > in some situations, in a way that cannot be trapped.[/color]

                  I have told you before, you start off with the OPTIONs defined in the
                  HTML and you test the dynamism of the browser by trying to remove them.
                  Then a worst case failure leaves those OPTIONs available to the user.
                  The same goes for the submit button, define it in the HTML and
                  conceal/remove it with a script and the whole implementation is much
                  simpler and no longer has any path that will leave the user without the
                  ability to use the form.

                  It is defining data/content for a script in any place other than
                  on the HTML page that is directly responsible for *needlessly*
                  introducing javascript dependency in the vast majority of scripts
                  that suffer from it. And it is a design decision, not something that
                  follows from the use of javascript as such.
                  [color=blue]
                  > You can't code for _every_ situation.[/color]

                  I can try.
                  [color=blue]
                  > Buggy browsers should not be supported.[/color]

                  Is there (or has there ever been) a single web browser that does not
                  have a bug?

                  All you are saying is that if a bug cannot be handled by your scripts as
                  you design them then it is the browser's fault, bugs your scripts can
                  cope with you don't consider a problem but that does not mean they are
                  not there (or are not bugs).
                  [color=blue][color=green]
                  >> This implementation would impose extra work on whoever was writing
                  >> the server-side scripts as they not only have to populate your
                  >> javascript data structures for the select list, but they also have
                  >> to implement the server-side fall back (and ensure that the two
                  >> interface styles make sense to the server-side code).[/color]
                  >
                  > Now you're really reaching, Richard :)
                  >
                  > Sure, it may be more work, but your argument was that it's not
                  > possible - not that it was easy and quick.[/color]

                  No, I think you will find that I said "it cannot be satisfactorily
                  implemented", which is not the same as impossible, and certainly does
                  include a consideration of how many hoops have to be jumped through in
                  order to implement it.
                  [color=blue]
                  > Lots of cool things are extra work. If a person wants this
                  > functionality on both server-side and client-side,
                  > then they can do the work.[/color]

                  Which was my point. If they do it exclusively on the server these is no
                  extra work, and if they use a client-side implementation that degrades
                  there is no extra work (even if the degraded interface is not that
                  usable in this instance), but if they use a javascript dependent
                  implementation, and want reliability, they have to put work in to
                  compensate for the script.

                  A design that lumbers someone else with extra work to compensate for its
                  shortcoming is not a good design. In a team context designing scripts to
                  minimise the effort needed for their employment by server-scripting
                  colleagues is the best plan. And that is easiest achieved by having the
                  scripts manipulate the HTML (and get their date from the HTML) because
                  server scripting is optimised for the creation of HTML and the people
                  doing it know how to understand and write out HTML. While presenting
                  them with new and complex javascript data structures to learn and
                  assemble on the server is unpopular, error prone and a sure way of
                  needlessly introducing javascript dependencies.

                  Designs based around the manipulation of HTML page content also offer
                  easy paths of clean degradation, and consequentially facilitate
                  reliability in the face of any browser environment.
                  [color=blue]
                  > Besides, both client-side code and server-side code would surely work
                  > off the same back-end logic, so outputing the requirement script
                  > calls surely would not be as much work as you would make it seem.[/color]

                  Above a certain level they are the same, but the specific form input
                  handling is very different. In a standard form handling script the input
                  from the HTTP request is validated and if it validates it is processed
                  and some sort of result response is generated, and if invalid it is
                  returned to the user for correction. You plan adding the handling of
                  partly completed form data and the construction of incremental stages in
                  the multiple selection.

                  The handler still has to do what it would have done otherwise but now it
                  is also interested in the user's current stage in the selection process
                  and re-assembling the party completed form to be returned to the user,
                  and it has to know at which point the form is finished so it can do the
                  validation instead. And if the form doesn't validate it is going to have
                  to handle the possibility that the user may want to change the
                  selection.

                  It is trivial to implement a progressive selection as a wizard style
                  interface with back and forward options but doing it all in one big
                  handler for a form introduces quite a lot that needs additional thought.
                  Plus the turnaround on the server would be slower if the whole form was
                  going back and forth each time.

                  Richard.


                  Comment

                  • Matt Kruse

                    #10
                    Re: two dropdown menus

                    Richard Cornford wrote:[color=blue]
                    > Two years ago I was
                    > writing scripts much like you write now[/color]

                    (first of all, much of the content of my site is not what I'm writing "now",
                    but has been there for a while... the latest addition was the DHTML tree,
                    which surely follows your design ideals)
                    [color=blue]
                    > but at least when I was introduced to the issues in
                    > browser scripting I was willing to recognise them an learn to handle
                    > them. Your complacency is going to mean that in two years time you
                    > are going to still be writing scripts much as you do now, and
                    > continuing to contribute towards making the Internet a worse place
                    > than it has to be.[/color]

                    Oh blah, Richard, your mantra bores me.
                    Considering that some of my code has been used by smany very major web sites
                    around the world, and my libraries have been useful to literally thousands
                    of web sites and saved the butts of many behind-schedule web developers, I
                    think you're being over-dramatic.

                    As with anything a person does over time, my skills have developed and I
                    could certainly now develop anything that you or anyone else could. I just
                    implemented a very slick UI using all DOM stuff that works beautifully in
                    all current browsers and even degrades nicely back to NN4. You'd be proud!
                    But unfortunately it's for a private webapp. :)
                    When I finish putting up content at http://www.javascripttoolbox.com/ then
                    I'll welcome your revised comments, because the code there will be more
                    representative of my current skills, and most certainly more in line with
                    your ideals. But as with most people with a family and kids, it's tough to
                    find time to even keep a web site current with new and better ways of doing
                    things! I know some problems in the scripts that are on my site, and I know
                    how to make them better and more robust, but I just don't have the time to
                    do so. Yet.

                    So quit the condescending crap. If you were offering up a bunch of solutions
                    for thousands of developers around the world to use and benefit from, and it
                    was always up-to-date and representative of the best coding ideals, then you
                    might be able to criticize. Offering theory - as you usually do - is much
                    _much_ _MUCH_ easier than maintaining a web site of examples, code, support,
                    and documentation.
                    [color=blue]
                    > That happens a lot, people who don't know any better lumber themselves
                    > with problems by choosing inappropriate scripts because those scripts
                    > are easy to find.[/color]

                    Would it not make sense for you to then offer "better" solutions so that
                    they can become popular and used everywhere?
                    I'm not sure you should be condemning users who offer solutions (and opening
                    themselves up to criticism) when you aren't prepared to offer any better
                    replacements. Telling the world that they are doing something wrong doesn't
                    carry much weight when you don't supply something better.
                    [color=blue]
                    > I have told you before, you start off with the OPTIONs defined in the
                    > HTML and you test the dynamism of the browser by trying to remove
                    > them.[/color]

                    a) This will not always work. I would _love_ for you to demonstrate this in
                    a cross-browser way that degrades nicely and doesn't break in any browsers.

                    b) The concept of "draw plain html and then go back and make it into fancy
                    dhtml" is good in theory, but not always in reality. I've had a number of
                    users complain that the screen is drawn, then "snaps" into place with a
                    better interface. "Why does the screen jump like that? Can you fix it?".
                    Things like changing a <ul> into a dhtml tree is different, because the same
                    structure is there. The page contents don't change drastically.
                    [color=blue][color=green]
                    >> You can't code for _every_ situation.[/color]
                    > I can try.[/color]

                    Good luck!
                    [color=blue][color=green]
                    >> Buggy browsers should not be supported.[/color]
                    > Is there (or has there ever been) a single web browser that does not
                    > have a bug?[/color]

                    No, of course not.
                    But if you're coding for dynamic select lists, and you know that Opera 5.02
                    can create Option objects but not add them to select lists, then that's a
                    very specific bug. Users of that browser should see things break, because
                    that's a big problem that cannot be reasonably tested for. In those
                    situations, I think it's better to inform the user that their browser sucks
                    then to change the whole way that a script functions to support the broken
                    browser.

                    --
                    Matt Kruse
                    Javascript Toolbox: http://www.JavascriptToolbox.com/


                    Comment

                    • Grant Wagner

                      #11
                      Re: two dropdown menus

                      Matt Kruse wrote:
                      [color=blue]
                      > Richard Cornford wrote:
                      >[color=green]
                      > > but at least when I was introduced to the issues in
                      > > browser scripting I was willing to recognise them an learn to handle
                      > > them. Your complacency is going to mean that in two years time you
                      > > are going to still be writing scripts much as you do now, and
                      > > continuing to contribute towards making the Internet a worse place
                      > > than it has to be.[/color]
                      >
                      > Oh blah, Richard, your mantra bores me.
                      > Considering that some of my code has been used by smany very major web sites
                      > around the world, and my libraries have been useful to literally thousands
                      > of web sites and saved the butts of many behind-schedule web developers, I
                      > think you're being over-dramatic.[/color]

                      And I've gotten a bit bored of your on-going desire to get the upperhand on
                      Richard. It's not going to happen, he is much more level-headed and presents
                      better arguments in a more informed manner. He does not resort to hyperbole
                      about "thousands of developers world-wide". Millions of people world-wide smoke
                      cigarettes too, it doesn't mean it's a good idea.

                      Even if you could provide audited logs proving your case, it would say nothing
                      about the quality of your work.

                      You've presented your code examples, you've made your opinions clear, you've
                      lost, move on.

                      --
                      | Grant Wagner <gwagner@agrico reunited.com>

                      * Client-side Javascript and Netscape 4 DOM Reference available at:
                      *


                      * Internet Explorer DOM Reference available at:
                      *
                      http://msdn.microsoft.com/workshop/a...ence_entry.asp

                      * Netscape 6/7 DOM Reference available at:
                      * http://www.mozilla.org/docs/dom/domref/
                      * Tips for upgrading JavaScript for Netscape 7 / Mozilla
                      * http://www.mozilla.org/docs/web-deve...upgrade_2.html


                      Comment

                      • Dr John Stockton

                        #12
                        Re: two dropdown menus

                        JRS: In article <caadvu$7hl$1$8 302bc10@news.de mon.co.uk>, seen in
                        news:comp.lang. javascript, Richard Cornford
                        <Richard@litote s.demon.co.uk> posted at Thu, 10 Jun 2004 20:49:16 :
                        [color=blue]
                        >It is difficult to judge the scope of the DDA as currently there is none
                        >of the required legal precedents as the cases that have been brought to
                        > ...
                        >And then there is the rest of the world, where any country may have, or
                        >introduce, its own legislation on the subject.[/color]

                        That's all rather legalistic.

                        By DAA, ADA, etc., Governments have formally recognised that those with
                        disabilities should not be disadvantaged where that can reasonably be
                        avoided.

                        But this has been known since Man's ancestors first became near-human;
                        although not always implemented.

                        The legal requirements should be considered as indicating a bare minimum
                        standard - though they also provide a tool that should be usable in
                        reasonable safety when attempting to persuade an obdurate
                        employer/client of the errors of his wishes - and authors/designers
                        should endeavour to provide a maximum of accessibility to all of the
                        target readership, whether or not they are formally recognised as
                        disabled.


                        Perhaps interested organisations should provide - and advertise - a
                        defaults-test page.

                        This page would be free of CSS (but should have <big> <small> <pre> and
                        default of each of the prime families of fonts, e.g. monospace), and
                        should strongly assert that :-

                        * it should be comfortably readable to most people using a normally set-
                        up browser on default or medium settings,
                        * people with minor disabilities should adjust their browser defaults to
                        make it comfortably readable,
                        * other people should seek browsers or other assistance appropriate to
                        their condition, in order to make the material as accessible as
                        possible;

                        and that, the above having been done, all material on the Web ought to
                        be accessible to them (except as unavoidably prevented by their
                        condition), and that if it is not the blame lies squarely with the page
                        provider.


                        The above doubtless needs adjustment; but it should give the general
                        idea.

                        --
                        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                        <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                        <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
                        <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

                        Comment

                        • Matt Kruse

                          #13
                          Re: two dropdown menus

                          Grant Wagner wrote:[color=blue]
                          > And I've gotten a bit bored of your on-going desire to get the
                          > upperhand on Richard. It's not going to happen, he is much more
                          > level-headed and presents better arguments in a more informed manner.[/color]

                          Well, I disagree, because he _consistantly_ fails to provide examples of his
                          ideas in action (all theory, no code).
                          He consistantly refuses to discuss specific things he finds wrong in any of
                          my code.
                          He consistantly ignores the fact that not everyone is designing in an
                          internet mode, supporting a wide scope of browsers.

                          And seriously, if he thinks he is correct in his opinions on the useage of
                          javascript on public web sites, I think he needs to look around the web a
                          bit. Some hugely popular sites employing many people who are surely at least
                          as intelligent as Richard have chosen to do things that conflict with his
                          design ideals. The world is not black-and-white. Just because someone
                          disagrees with his ideas does not mean they are wrong or less intelligent.

                          I'm tired of his continued posts saying things are not done correctly, when
                          he offers no technical criticisms at all. When asked to do so, he refuses.
                          He's all talk.
                          [color=blue]
                          > He does not resort to hyperbole about "thousands of developers
                          > world-wide". Millions of people world-wide smoke cigarettes too, it
                          > doesn't mean it's a good idea.[/color]

                          That's completely unrelated. And not a hyperbole at all.

                          It's similar to the linux-freaks who bash microsoft on a regular basis,
                          pointing out how badly Windows handles a lot of things. In many cases,
                          they're right. But so what? Millions of people use Windows every day and it
                          fits their needs perfectly and enables them to work better. Just because
                          Windows isn't perfect doesn't mean it has no value, or that its use should
                          be discouraged. Quite the opposite.

                          Similarly, my point is this - if some of my libraries are used by thousands
                          of developers, and they find value in them, and there are a couple of people
                          who say "yeah, but that's not the ideal way to do it!"... so what? Are those
                          nay sayers adding the same value in ways that they find to be correct, or
                          are they just whining?
                          [color=blue]
                          > Even if you could provide audited logs proving your case, it would
                          > say nothing about the quality of your work.[/color]

                          My point is, it's peer-reviewed. Lots of web developers use the code, and it
                          solves their problems. Nothing is perfect, and I don't claim that anything
                          of mine is. Obviously, not _every_ peer agrees with it.

                          But I don't put much weight in theories and opinions expressed by an
                          extremely negative guy whose goal in life seems to be to tell people why
                          they are stupid and doing things the wrong way, yet not providing his "good"
                          solutions up for the world to use, review, and criticize. If there are
                          better ways to do what my code does, then by all means DEMONSTRATE IT.

                          But the response to that often is, "well, you shouldn't be doing that at
                          all." Which is a view from Utopia. I'm sure there are countless developers a
                          day who receive the requirement of "there should be a popup calendar to pick
                          a date". You or Richard may say that's a stupid requirement that shouldn't
                          be implemented, but that doesn't change the fact that there are lots of
                          people who WILL implement it because they DO need it. If I supply a great
                          solution that they can plug in without spending hours of work developing it
                          from scratch, I've added value. And that's bad?
                          [color=blue]
                          > You've presented your code examples, you've made your opinions clear,
                          > you've lost, move on.[/color]

                          heh, you can have that opinion, that's fine... but the emails I get, the
                          places I see my code used, and the daily donations I receive lead me to a
                          different conclusion ;)

                          --
                          Matt Kruse
                          Javascript Toolbox: http://www.JavascriptToolbox.com/


                          Comment

                          • Mike Foster

                            #14
                            Re: two dropdown menus

                            On Thu, 10 Jun 2004 11:03:26 +0000 (UTC), Continental Translations <neilgreenough@ btopenworld.com > wrote:
                            [color=blue]
                            > Can anybody help me? I am trying to create two drop down menus, where the
                            > results of the second one vary depending on what was selected in the first
                            > one. I am using MS Script Editor in MS Front Page to do this.
                            >
                            > In my first menu, I want "English" "German" and "Russian."
                            >
                            > Now if "English" is picked, I want "French" "German" and "Spanish" to
                            > appear.
                            > If "German" is picked in the first menu, I want "English" to appear"
                            > If Russian is picked in the first menu, I want "Dutch" to appear.
                            >
                            > Any advice? I ain't clued up that much on Javascript!
                            >
                            > Thanks all
                            >
                            >
                            >[/color]


                            Here's yet another demo for this type of thing :-)


                            Comment

                            • Yann-Erwan Perio

                              #15
                              Re: two dropdown menus

                              Matt Kruse wrote:

                              Hi,
                              [color=blue]
                              > Well, I disagree, because he _consistantly_ fails to provide examples of his
                              > ideas in action (all theory, no code).[/color]

                              If you want to see some of his scripts, try looking at the website he's
                              posting from, or search his posts in the comp.lang.javas cript archives
                              (there are many lengthty interesting pieces of code).
                              [color=blue]
                              > And seriously, if he thinks he is correct in his opinions on the useage of
                              > javascript on public web sites, I think he needs to look around the web a
                              > bit. Some hugely popular sites employing many people who are surely at least
                              > as intelligent as Richard have chosen to do things that conflict with his
                              > design ideals.[/color]

                              That's unfortunately true, but did they really have the choice? IMHO
                              they just didn't know any better, web scripting has never been
                              considered a serious matter and they've never taken the time to
                              understand the context or the language.

                              Since you're in contact with many professionals, test by yourself: how
                              many have read and understood the ECMA-262v3 specification? How many are
                              aware of functional programming in javascript (closures)? How many are
                              able to use advanced javascript OO-based patterns (using private static
                              members for instance)? How many have read and understood the relevant
                              W3C specs (DOM Core, DOM Events, DOM Traversal & Ranges, HTML4.0,
                              CSS2.1)? Have they read and experienced accessibility guidelines?


                              You're posting in comp.lang.javas cript, with regulars who have spent
                              countless hours on the specs, who have written thousands (and probably
                              millions) lines of javascript, testing, twisting the language,
                              elaborating and applying endlessly design patterns - people who love
                              javascript and therefore have the highest expectations. Now it's
                              certainly true that some of the opinions expressed here are "black or
                              white", but that's because they take into account every aspect to build
                              the _best_ application - there's no toning down quality for bad reasons.

                              Richard's teasing on your posts has probably the only goal to have you,
                              a definitely skilled programmer, reach the highest levels.


                              Regards,
                              Yep.

                              Comment

                              Working...