Big menu

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

    Big menu

    Hello all,

    i'm generating a select menu, with php/mysql. The menu contains country names.

    My problem is that i have ~ 250 countries in one of these menu and i need from
    6 to ten times this menu in a web page.

    Is there any way for sharing the data between each menu? It should speed up
    transfert and decrease size of the web page.

    Thx

    --
    David

  • Lasse Reichstein Nielsen

    #2
    Re: Big menu

    david <pas.d.email@se rver.com> writes:
    [color=blue]
    > i'm generating a select menu, with php/mysql. The menu contains
    > country names.
    >
    > My problem is that i have ~ 250 countries in one of these menu and i
    > need from 6 to ten times this menu in a web page.[/color]

    Whoa. with 250 options in a select element, you might want to consider
    other ways of choosing (not sure which would be better, though, 250
    options is a lot).
    [color=blue]
    > Is there any way for sharing the data between each menu? It should speed up
    > transfert and decrease size of the web page.[/color]

    Yes, but then your page will not work if Javascript is disabled.
    ---
    <script type="text/javascript">
    function copyOptions(idF rom,idTo) {
    var from = document.getEle mentById(idFrom );
    var to = document.getEle mentById(idTo);
    // maybe add sanity check: does both exist and are select elements
    to.length = 0;
    for (var i=0;i<from.leng th;i++) {
    var opt = from.options[i];
    to.options[i]=new Option(opt.text ,opt.value);
    }
    }

    function init() {
    copyOptions("co untrySel1","cou ntrySel2");
    copyOptions("co untrySel1","cou ntrySel3");
    copyOptions("co untrySel1","cou ntrySel4");
    copyOptions("co untrySel1","cou ntrySel5");
    copyOptions("co untrySel1","cou ntrySel6");
    }
    </script>
    ---
    and
    ---
    <body onload="init()" >
    ... <select id="countrySel1 "><option>x250. ..</select>
    ... <select id="countrySel2 "></select>
    ... <select id="countrySel3 "></select>
    ---

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • david

      #3
      Re: Big menu

      Lasse Reichstein Nielsen wrote:[color=blue]
      > david <pas.d.email@se rver.com> writes:[/color]
      [color=blue][color=green]
      >>i'm generating a select menu, with php/mysql. The menu contains
      >>country names.
      >>
      >>My problem is that i have ~ 250 countries in one of these menu and i
      >>need from 6 to ten times this menu in a web page.[/color][/color]
      [color=blue]
      > Whoa. with 250 options in a select element, you might want to consider
      > other ways of choosing (not sure which would be better, though, 250
      > options is a lot).[/color]

      well, a select your country menu is widely present on the web though...

      [color=blue][color=green]
      >>Is there any way for sharing the data between each menu? It should speed up
      >>transfert and decrease size of the web page.[/color][/color]
      [color=blue]
      > Yes, but then your page will not work if Javascript is disabled.[/color]

      that's already the case :(

      [color=blue]
      > ---
      > <script type="text/javascript">
      > function copyOptions(idF rom,idTo) {
      > var from = document.getEle mentById(idFrom );
      > var to = document.getEle mentById(idTo);
      > // maybe add sanity check: does both exist and are select elements
      > to.length = 0;
      > for (var i=0;i<from.leng th;i++) {
      > var opt = from.options[i];
      > to.options[i]=new Option(opt.text ,opt.value);
      > }
      > }
      >
      > function init() {
      > copyOptions("co untrySel1","cou ntrySel2");
      > copyOptions("co untrySel1","cou ntrySel3");
      > copyOptions("co untrySel1","cou ntrySel4");
      > copyOptions("co untrySel1","cou ntrySel5");
      > copyOptions("co untrySel1","cou ntrySel6");
      > }
      > </script>
      > ---
      > and
      > ---
      > <body onload="init()" >
      > ... <select id="countrySel1 "><option>x250. ..</select>
      > ... <select id="countrySel2 "></select>
      > ... <select id="countrySel3 "></select>
      > ---[/color]

      thx but with this, the size of the web page is smaller, but the HTML tree in
      the browser memory ends up with the same size... it's not exactely what i
      wanted but, i may use the trick later.

      Thx again :)

      --
      David

      Comment

      Working...