I have a question if someone could help me. I need to make an ajax enabled feedback form that asks for info. I have an XML page with a list of email addresses on it. When the feedback form is submitted and one of the email addresses is on the XML page a message is displayed. I am having trouble understanding how to do the feedback form. I think I have the XML page done correctly. I have tried to do the feedback form but I am not even sure I am understanding it right cause well it is not working so that is my first sign
. Could someone please help me understand what I need to do please. Thank You
Here is my XML page "address.xml".
<?xml version="1.0"?>
<address>
<address>
<email>frautani@ymail.com</email>
</address>
<address>
<email>stella@ymail.com</email>
</address>
<address>
<email>timster@aol.com</email>
</address>
</address>
Here is my lame try at the feedback form "squid.html".
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript">
var asyncRequest;
function clearEmail()
{
document.getElementById("address").innerHTML="";
}
function getEmail(file)
{
asyncRequest = new XMLHttpRequest();
asyncRequest.onreadystatechange = processResponse;
asyncRequest.open("GET", file, true);
asyncRequest.send(null);
}
function processResponse()
{
if (asyncRequest.readyState == 4 &&
asyncRequest.status == 200)
{
clearEmail();
var address = asyncRequest.responseXML.getElementsByTagName("address");
var output = document.getElementById("email");
for (var index = 0; index < address.length; index++)
{
var email = address.item(index);
address.appendChild(email);
output.appendChild(email);
}
}
}
</script>
</head>
<body>
<head>
<script>
<h1>Register</h1>
<form method="get" action="">
<h2>Please Register For A Christmas Basket!</h2></br>
<h3>The Following Information Will Be Needed!</h3>
<label for="fullName">Full Name</label>
<input type="text" name="fullName" size="50"/>
</br>
<label for="street">Address</label>
<input type="text" name="street" size="50"/>
</br>
<label for="city">City</label>
<input type="text" name="city" size="50"/>
</br>
<label for="state">State</label>
<input type="text" name="state" size="2"/>
</br>
<label for="zip">Zip Code</label>
<input type="text" name="zip" size="5"/>
</br>
<label for="address">Email</label>
<input type="text" name="address" size="50"/>
value="address" id="address" onclick="getEmail('address.xml')" />
</script>
</body>
</form>
</html>