Posted By

miziomon on 11/13/07


Tagged

ajax select Fill


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

arcturus
vali29
hariharank12
umang_nine


Select ajax DOM Fill


 / Published in: JavaScript
 

URL: http://maurizio.mavida.com/2005/11/27/modificare-le-select-con-dom-javascript-e-ajax/

  1. <html>
  2. <head>
  3. <title>Select ajax DOM Fill</title>
  4. <script type="text/javascript" src="XHConn.js"></script>
  5. </head>
  6. <body>
  7. <script type="text/javascript">
  8. function fill( ) {
  9. var fnCarica = function (oGet) {
  10. objSelect = document.getElementById('elemento-select') ;
  11. var sJSON = oGet.responseText;
  12.  
  13. var oJSON = eval(sJSON);
  14. var nOpt
  15. for( nOpt=0;nOpt<oJSON.length;nOpt++) {
  16. objSelect.options[objSelect.options.length] = new Option( oJSON[nOpt].text , oJSON[nOpt].value )
  17. };
  18. };
  19. new XHConn().connect('fill.txt', 'GET', '' , fnCarica);
  20. }
  21. </script>
  22. <select id="elemento-select">
  23. <option value="valore1">etichetta1</option>
  24. <option value="valore2">etichetta2</option>
  25. <option value="valore3">etichetta3</option>
  26. </select>
  27. <button onclick="fill()">bau</button>
  28. </body>
  29. </html>

Report this snippet  

You need to login to post a comment.