1) Script Title: Javascript does not work upon AJAX call
2)Script URL(DD):http://www.dynamicdrive.com/forums/s...ad.php?t=13003
3) Describe problem:
I have a page which does an AJAX call and loads an entire page. The page that gets loaded has some Javascript. The javascript works on page by itself when loaded, but when its gets loaded by AJAX, the Javascript does not work. I dont know what I am missing.


The code of the loaded page is


Code:
<html>
<script type="text/javascript">
function showfield(name){
if(name=='lstbox')document.getElementById('div1').style.display="block";
else document.getElementById('div1').style.display="none";
}

function hidefield() {
document.getElementById('div1').style.display='none';
}

</script>

<head>
</head>
<body onload="hidefield()">
<form action = "test2.php" method = "post">

Please enter a name for the App <input type = "text" name = "name">

<table border = "1"><tr><th>Choose a Label</th><th>Choose an element</th></tr>

<tr><td><input type = "text" name = "label1" /></td> <td> 

<select name = "elementtype1" id="elementtype1" onchange="showfield(this.options[this.selectedIndex].value)">

<option value = 'select'> Select </option>

<option value='txtbox'>Text Box</option>

<option value='lstbox'>List Box</option>

<option value='chkbox'>Check Box</option>

<option value='radio'>Radio Button</option>

</select></td><td><div id="div1">Enter Listbox options: <input type="text" name="whatever1" /></div></td></tr>

</table>

<input type = "submit" value = "Submit">

</form>

</body>

</html>
The code of the loading(AJAX) page is

Code:
<html>
<head>
</head>
<body>

<script src="ajax.js" type="text/javascript"></script>
<script src="responseHTML.js" type="text/javascript"></script>

<div id="storage" style="display:none;">
</div>

<div id="displayed">



<FORM name="ajax" method="POST" action="">
	<p>
		
    <INPUT type="BUTTON" value="Get the Panel"  ONCLICK="loadWholePage('appcreator.php')">

	</p>
		
</FORM>
</div>



</body>
</html>