probleme inserare form

Discutii legate de AJAX, jQuery, MooTools, Prototype, Dojo, Yahoo! UI Library,script.aculo.us, ExtJS,AngularJS, Backbone.js, Ember.js, KnockoutJS

Moderator: Moderatori

nexochillax
PHPRomania Supporter
Mesaje: 5
Membru din: Sâm Oct 19, 2013 9:33 pm

probleme inserare form

Mesajde nexochillax » Dum Noi 03, 2013 6:27 pm

Salut baieti

am o problema de inserare

Cod: Selectaţi tot

<script type="text/javascript">
   function getStates()
   {
      var xmlhttp;
      try {
           xmlhttp = new XMLHttpRequest;
      }catch(e)
      {
         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
        if(xmlhttp)
        {
         var form = document['form1'];
         var country = form['country'].value;

         xmlhttp.open("GET", "getStates.php?country="+country, true);

         xmlhttp.onreadystatechange = function ()
         {
             if(this.readyState == 4)
             {
            var s = document.createElement("select");
            s.name= "state";
            s.innerHTML = this.responseText;

            if(form['state'])
            {
               form.replaceChild(s, form['state']);
            }else
               form.insertBefore(s, form['country']);
             }
         }
                         
          xmlhttp.send(null);

        }
     }
   </script>



Acesta este codul si as dori sa-mi afiseze formul state dupa formul country

Am incercat ci insertAfter dar nu merge

Tin sa mentionez ca nu stiu prea multe despre AJAX dar stiu ce fac daca ma uit peste cod.

O zi buna



marianmp
Average Member
Mesaje: 190
Membru din: Mie Noi 09, 2011 1:12 pm
Localitate: https://micul-programator.ro
Contact:

Re: probleme inserare form

Mesajde marianmp » Vin Ian 31, 2014 11:06 am

nexochillax scrie:Salut baieti

am o problema de inserare

Cod: Selectaţi tot

<script type="text/javascript">
   function getStates()
   {
      var xmlhttp;
      try {
           xmlhttp = new XMLHttpRequest;
      }catch(e)
      {
         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
        if(xmlhttp)
        {
         var form = document['form1'];
         var country = form['country'].value;

         xmlhttp.open("GET", "getStates.php?country="+country, true);

         xmlhttp.onreadystatechange = function ()
         {
             if(this.readyState == 4)
             {
            var s = document.createElement("select");
            s.name= "state";
            s.innerHTML = this.responseText;

            if(form['state'])
            {
               form.replaceChild(s, form['state']);
            }else
               form.insertBefore(s, form['country']);
             }
         }
                         
          xmlhttp.send(null);

        }
     }
   </script>



Acesta este codul si as dori sa-mi afiseze formul state dupa formul country

Am incercat ci insertAfter dar nu merge

Tin sa mentionez ca nu stiu prea multe despre AJAX dar stiu ce fac daca ma uit peste cod.

O zi buna



foloseste jquery http://micul-programator.ro/index.php?p ... tutorial-1 , se face acel ajax? da un rezultat ?


Înapoi la “Librarii Javascript”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 23 vizitatori