Autor Zpráva
sonicer
Profil *
//jquery.ares.js 
(function($) { 
        $.ares = function(idNumber, options) { 
            var defaults = { 
                url: 'http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi?ico=--idNumber--', 
                gateway: 'ajax-gateway.php?url=--url--', 
                finished: null,  
                notfound: null, 
            }; 

            var opts = $.extend(defaults, options); 
             
            var url = opts.gateway.replace('--url--',  
                        opts.url.replace('--idNumber--', idNumber)); 
           
            $.get(url, function(data) { 
                var xml = $(data); 
                if (xml.find('D\\:E').length == 1) { 
                    // Chyba! 
                    if ($.isFunction(opts.notfound)) { 
                        opts.notfound.call(this); 
                    }  
                } else { 
                    if ($.isFunction(opts.finished)) { 
                        var obj = {}; 
                        obj.idNumber = xml.find('D\\:ICO').html(); 
                        obj.vatNumber = xml.find('D\\:DIC').html(); 
                        obj.name = xml.find('D\\:OF').html(); 
                        obj.country = xml.find('D\\:NS').html(); 
                        obj.city = xml.find('D\\:N').html(); 
                        obj.cityPart = xml.find('D\\:NCO').html(); 
                        obj.street = xml.find('D\\:NU').html() + ' ' + xml.find('D\\:CD').html(); 
                        if (xml.find('D\\:CO').html().trim() != '') { 
                            obj.street += '/' + xml.find('D\\:CO').html();   
                        }                     
                        obj.postalCode = xml.find('D\\:PSC').html(); 
                        opts.finished.call(this, obj); 
                    } 
                } 
            });
            

        }         
})(jQuery); 

chtěl bych jednotlivé výsledky dát do formuláře tedy předvyplnit....a to např.postalcode bych chtěl dostat do <input value hodnoty.

díky za rady.
peta
Profil
Odkaz na funkcni kod? Nevidim zadne inputy, neda se to zkopirovat do souboru a spustit.

Kdyz pridas pod tento radek alert, tak to nevypise postalcode? Nebo, v cem je chyba? Neumis v jquery ulozit hodnotu do html tagu? To v dokumentaci jquery nejsou priklady?
obj.postalCode = xml.find('D\\:PSC').html(); 
alert(obj.postalCode);

http://api.jquery.com/category/forms/
http://api.jquery.com/val/
Example: Set the value of an input box.

<!DOCTYPE html>
<html>
<head>
  <style>
  button { margin:4px; cursor:pointer; }
  input { margin:4px; color:blue; }
  </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <div>
    <button>Feed</button>
    <button>the</button>
    <button>Input</button>
  </div>
  <input type="text" value="click a button" />
<script>
    $("button").click(function () {
      var text = $(this).text();
      $("input").val(text);
    });
</script>

</body>
</html>

Vaše odpověď

Mohlo by se hodit

Neumíte-li správně určit příčinu chyby, vkládejte odkazy na živé ukázky.
Užíváte-li nějakou cizí knihovnu, ukažte odpovídajícím, kde jste ji vzali.

Užitečné odkazy:

Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0