Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: appendChild i tablica _POST
Forum PHP.pl > Forum > Po stronie przeglądarki > JavaScript
misiek172
Witam.

Od rana walczę w pewnym głupim problemem , mianowicie:

napisałem sobie skrypt generujący mi selecty z datą, wybiera sie dzień miesiąc i rok, wszystko ok pod IE i FF ładnie się wyświetla SELECT (robie to za pomocą appendChild) tylko problem jest taki że po wysłaniu formularza w tablicy _POST są dane ale tylko gdy wysyłam pod FF, jak wyśwle pod IE to selecty mają puste wartości...

dlaczego tak jest?

Pozdrawiam, Łukasz.
wookieb
A może byś łaskawco pokazał kod?
misiek172
ale co mam ci pokazywac biggrin.gif

createElement

potem atrybuty

i appendChild do diva smile.gif

a taki kodzik:

  1. <?php
  2. function day(v){
  3.    var Day = today.getDate();
  4.    for(var y=1;y<=31;y++){
  5.        var theOption=d.createElement("OPTION");
  6.        theText=d.createTextNode(y<10?'0'+y:y);
  7.        theOption.appendChild(theText);
  8.        v.appendChild(theOption);
  9.    }
  10.    v.options[--Day].selected = true;
  11.    //v.options.selectedIndex = 2;
  12. }
  13. function month(v){
  14.    var Day = today.getMonth();
  15.    for(var y=1;y<=12;y++){
  16.        var theOption=d.createElement("OPTION");
  17.        theText=d.createTextNode(y<10?'0'+y:y);
  18.        theOption.appendChild(theText);
  19.        v.appendChild(theOption);
  20.    }
  21.    v.options[Day].selected = true;
  22. }
  23. function year(v){
  24.    var Day = today.getFullYear();
  25.    for(var y=Day;y>=2007;y--){
  26.        var theOption=d.createElement("OPTION");
  27.        theText=d.createTextNode(y<10?'0'+y:y);
  28.        theOption.appendChild(theText);
  29.        v.appendChild(theOption);
  30.    }
  31. }
  32. function createDataSelect(name)
  33. {
  34.    var v=d.createElement('select');
  35.    v.setAttribute('name',name+i);
  36.    
  37.    switch (i)
  38.    {
  39.        case 0 : day(v); break;
  40.        case 1 : month(v); break;
  41.        case 2 : year(v); break;
  42.    }
  43.  
  44.    theText=d.createTextNode(' - ');
  45.    var divek = document.getElementById(name);
  46.    divek.appendChild(v);
  47.    if(i!=2)
  48.        divek.appendChild(theText);
  49.    i++;
  50.    if(i<3){
  51.        createDataSelect(name);
  52.    }else{
  53.        i = 0;
  54.        done = 1;
  55.    }
  56.  
  57. }
  58. ?>


edit:

ok dodałem atrybut value dla option'ów i działa elegancko pod IE, pozdr.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.