Wie kan mij helpen met het volgende
In het volgende stuk javascript code vul ik eerst de array : testarray met functie haaldata().
Deze wordt vanuit een xml file gevuld. Dit gaat goed
Vervolgens wordt met functie schrijfdata() de inhoud op het scherm getoond.
Ik krijg met geen mogelijkheid de data in testarry op het scherm getoond.
Het lijkt erop dat de inhoud van deze array alleen bestaat binnen functie haaldata().
Graag jullie hulp hierbij.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Naamloos document</title>
<script type="text/javascript" src="jquere/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
function initialize(){
var Windsterkte;
var testarray = [];
document.myform.outputtext.value += ( "Data uit XML file positie.xml " + " \n");
haaldata();
schrijfdata();
function haaldata(){
$.get("positie.xml",{},function(xml){
$('Positie',xml).each(function(i) {
Windsterkte = $(this).find("Wind").text();
testarray = Windsterkte;
document.myform.outputtext.value += ( i + " " + Windsterkte + " " + testarray + " \n" );
});
});
};
} // einde haaldata
function schrijfdata() {
for (var i1 = 0; i1 < testarray.length; i1++) {
document.myform.outputtext.value += ( i1 + " " + testarray[i1] + " \n" );
} // einde schrijfdata
} // einde initialize
</script>
</head>
<body onload="initialize()">
<form name="myform">
<td width="448" height="180"> <td><textarea name="outputtext" rows="10"></textarea></td>
</body>
</html>
met de xml file positie.xml
<?xml version="1.0" encoding="utf-8"?>
<Posities>
<Positie>
<Wind>13.0</Wind>
</Positie>
<Positie>
<Wind>12.0</Wind>
</Positie>
</Posities>
In het volgende stuk javascript code vul ik eerst de array : testarray met functie haaldata().
Deze wordt vanuit een xml file gevuld. Dit gaat goed
Vervolgens wordt met functie schrijfdata() de inhoud op het scherm getoond.
Ik krijg met geen mogelijkheid de data in testarry op het scherm getoond.
Het lijkt erop dat de inhoud van deze array alleen bestaat binnen functie haaldata().
Graag jullie hulp hierbij.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Naamloos document</title>
<script type="text/javascript" src="jquere/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
function initialize(){
var Windsterkte;
var testarray = [];
document.myform.outputtext.value += ( "Data uit XML file positie.xml " + " \n");
haaldata();
schrijfdata();
function haaldata(){
$.get("positie.xml",{},function(xml){
$('Positie',xml).each(function(i) {
Windsterkte = $(this).find("Wind").text();
testarray = Windsterkte;
document.myform.outputtext.value += ( i + " " + Windsterkte + " " + testarray + " \n" );
});
});
};
} // einde haaldata
function schrijfdata() {
for (var i1 = 0; i1 < testarray.length; i1++) {
document.myform.outputtext.value += ( i1 + " " + testarray[i1] + " \n" );
} // einde schrijfdata
} // einde initialize
</script>
</head>
<body onload="initialize()">
<form name="myform">
<td width="448" height="180"> <td><textarea name="outputtext" rows="10"></textarea></td>
</body>
</html>
met de xml file positie.xml
<?xml version="1.0" encoding="utf-8"?>
<Posities>
<Positie>
<Wind>13.0</Wind>
</Positie>
<Positie>
<Wind>12.0</Wind>
</Positie>
</Posities>