Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Submit forme ne radi u IE ako koristim JS dynamic select.

[es] :: Javascript i AJAX :: Submit forme ne radi u IE ako koristim JS dynamic select.

[ Pregleda: 1754 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

extramedia
Nemanja Milenkovic
Padinska Skela

Član broj: 78055
Poruke: 95
*.wifi.gonet1.co.yu.



Profil

icon Submit forme ne radi u IE ako koristim JS dynamic select.26.03.2007. u 17:04 - pre 207 meseci
Dakle evo JS coda:
Code:
function dynamicSelect(id1, id2) {
    // Feature test to see if there is enough W3C DOM support
    if (document.getElementById && document.getElementsByTagName) {
        // Obtain references to both select boxes
        var sel1 = document.getElementById(id1);
        var sel2 = document.getElementById(id2);
        // Clone the dynamic select box
        var clone = sel2.cloneNode(true);
        // Obtain references to all cloned options 
        var clonedOptions = clone.getElementsByTagName("option");
        // Onload init: call a generic function to display the related options in the dynamic select box
        refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
        // Onchange of the main select box: call a generic function to display the related options in the dynamic select box
        sel1.onchange = function() {
            refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
        };
    }
}
function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) {
    // Delete all options of the dynamic select box
    while (sel2.options.length) {
        sel2.remove(0);
    }
    // Create regular expression objects for "select" and the value of the selected option of the main select box as class names
    var pattern1 = /( |^)(select)( |$)/;
    var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
    // Iterate through all cloned options
    for (var i = 0; i < clonedOptions.length; i++) {
        // If the classname of a cloned option either equals "select" or equals the value of the selected option of the main select box
        if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
            // Clone the option from the hidden option pool and append it to the dynamic select box
            sel2.appendChild(clonedOptions[i].cloneNode(true));
        }
    }
}
// Attach our behavior onload
window.onload = function() {
    dynamicSelect("prm_country_id", "prm_region_id");
}


A evo i HTML forme:
Code:

<form action="process_data.php?cmd=update_pr_general" method="post" enctype="application/x-www-form-urlencoded" name="form1" id="form1">
          <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="160" valign="top"><p>Title:</p></td>
              <td valign="top"><p>
                  <input name="prm_title" type="text" id="prm_title" value="Testing... dont delete me, just rename me." size="60" />
                  <span class="info_text">*</span></p></td>

            </tr>
            <tr>
              <td valign="top"><p>Ref. number: </p></td>
              <td valign="top"><p>
                  <input name="prm_ref" type="text" id="prm_ref" value="2121" size="10" />
                  <span class="info_text">*</span></p></td>
            </tr>
            <tr>

              <td valign="top"><p>Price:</p></td>
              <td valign="top"><p>
                  <input name="prm_price" type="text" id="prm_price" value="231321" size="10" />
                  <span class="info_text">*</span></p></td>
            </tr>
            <tr>
              <td valign="top"><p>Type:</p></td>

              <td valign="top"><p>
                  <select name="prm_type" size="1" id="prm_type">
                                        <option value="2">Apartment</option>
                                        <option value="3"selected="selected">Townhouse</option>
                                        <option value="4">Villa</option>
                                      </select>
              </p></td>

            </tr>
            <tr>
              <td valign="top"><p>No. bedrooms: </p></td>
              <td valign="top"><p>
                  <input name="prm_bedrooms" type="text" id="prm_bedrooms" value="21" size="10" />
                  <span class="info_text">*</span></p></td>
            </tr>
            <tr>

                            <td valign="top"><p>Completed on: </p></td>
              <td valign="top"><p> Month:
                <select name="date_month" size="1" id="date_month">
                                                <option value="1" selected="selected">1</option>
                                                <option value="2" >2</option>
                                                <option value="3" >3</option>
                                                <option value="4" >4</option>

                                                <option value="5" >5</option>
                                                <option value="6" >6</option>
                                                <option value="7" >7</option>
                                                <option value="8" >8</option>
                                                <option value="9" >9</option>
                                                <option value="10" >10</option>

                                                <option value="11" >11</option>
                                                <option value="12" >12</option>
                                              </select>
                Year:
                <select name="date_year" size="1" id="date_year">
                                    <option value="2006" selected="selected">2006</option>
                                    <option value="2007" >2007</option>

                                    <option value="2008" >2008</option>
                                    <option value="2009" >2009</option>
                                    <option value="2010" >2010</option>
                                    <option value="2011" >2011</option>
                                    <option value="2012" >2012</option>
                                    <option value="2013" >2013</option>

                                    <option value="2014" >2014</option>
                                    <option value="2015" >2015</option>
                                    <option value="2016" >2016</option>
                                    <option value="2017" >2017</option>
                                    <option value="2018" >2018</option>
                                    <option value="2019" >2019</option>

                                    <option value="2020" >2020</option>
                                    <option value="2021" >2021</option>
                                    <option value="2022" >2022</option>
                                  </select>
              </p></td>
            </tr>
            <tr>

              <td valign="top"><p>Country:</p></td>
              <td valign="top"><p>
                  <select name="prm_country_id" size="1" id="prm_country_id">
                    <option value="select" >Select a country</option>
                                        <option value="3">Egypt</option>
                                        <option value="1"selected="selected">Morocco</option>
                                      </select>

                  <span class="info_text">*</span></p></td>
            </tr>
            <tr>
              <td valign="top"><p>Region:</p></td>
              <td valign="top"><p>
                  <select name="prm_region_id" size="1" id="prm_region_id">
                    <option class="select" value="select" >Select a region</option>

                                        <option class="1" value="1"selected="selected">Agadir</option>
                                        <option class="1" value="4">Tangier</option>
                                        <option class="3" value="5">Hurghada</option>
                                        <option class="1" value="6">Marrakech</option>
                                        <option class="1" value="8">Tetouan</option>
                                      </select>

                  <span class="info_text">*</span></p></td>
            </tr>
            <tr>
              <td valign="top"><p>Details:</p></td>
              <td valign="top"><p>
                  <textarea name="prm_details" cols="90" rows="15" id="prm_details"></textarea>
              </p></td>

            </tr>
            <tr>
              <td valign="top"><p>META Description tag </p></td>
              <td valign="top"><p>
                <input name="prm_meta_desc" type="text" id="prm_meta_desc" value="I am a testing META description tag" size="100" />
              </p></td>
            </tr>
            <tr>

              <td valign="top">&nbsp;</td>
              <td valign="top"><p>
                  <input type="submit" name="submit" value="UPDATE PROPERTY" />
                  <input name="prm_id" type="hidden" id="prm_id" value="32" />
              </p></td>
            </tr>
          </table>          
        </form>


U FFoxu i ostalima radi sve ok, a u IE se ne deshava nista kada se klikne na submit dugme. To jest desava se, ponovo se ucita ista strana a podaci ostaju nepromenjeni.
Kada uklonim <scripT> tag sa pomenutim JS-om, radi sve kako treba u IE. Taj JS inace koristim za dinamicko selektovanje Drzava i regiona.

Zna li iko u cemu je caka osim u tome shto je IE generalno shit ?
 
Odgovor na temu

[es] :: Javascript i AJAX :: Submit forme ne radi u IE ako koristim JS dynamic select.

[ Pregleda: 1754 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.