Return to Snippet

Revision: 4244
at November 13, 2007 06:06 by miziomon


Updated Code
<html>
	<head>
		<title>Select ajax DOM Fill</title>
		<script type="text/javascript" src="XHConn.js"></script>
	</head>
	<body>
	<script type="text/javascript">
	function fill( ) {
	  var fnCarica = function (oGet) {  
		objSelect = document.getElementById('elemento-select') ;
		var sJSON = oGet.responseText;
		
		var oJSON = eval(sJSON);    
		var nOpt
		for( nOpt=0;nOpt<oJSON.length;nOpt++) { 
			objSelect.options[objSelect.options.length] = new Option( oJSON[nOpt].text , oJSON[nOpt].value )    
		 };
	  };
	  new XHConn().connect('fill.txt', 'GET', '' , fnCarica);
	}
	</script>
	<select id="elemento-select">
		<option value="valore1">etichetta1</option>
		<option value="valore2">etichetta2</option>
		<option value="valore3">etichetta3</option>
	</select>
	<button onclick="fill()">bau</button>
	</body>
</html>

Revision: 4243
at November 13, 2007 05:57 by miziomon


Initial Code
<html>
	<head>
		<title>Select ajax DOM Fill</title>
		<script type="text/javascript" src="XHConn.js"></script>

	</head>
	<body>

	<script type="text/javascript">
	function fill( ) {
	  var fnCarica = function (oGet) {  
		objSelect = document.getElementById('elemento-select') ;
		var sJSON = oGet.responseText;
		
		var oJSON = eval(sJSON);    
		var nOpt
		for( nOpt=0;nOpt<oJSON.length;nOpt++) { 
			objSelect.options[objSelect.options.length] = new Option( oJSON[nOpt].text , oJSON[nOpt].value )    
		 };
	  };

	  new XHConn().connect('fill.txt', 'GET', '' , fnCarica);
	}

	</script>
	
	<select id="elemento-select">
	
	<option value="valore1">etichetta1</option>
		<option value="valore2">etichetta2</option>
		<option value="valore3">etichetta3</option>
	</select>

	<button onclick="fill()">bau</button>


	</body>
</html>

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

Initial Description

                                

Initial Title
Select ajax DOM Fill

Initial Tags
ajax

Initial Language
JavaScript