Quote:
Originally Posted by mrmodest
The quotes look like they should in my notepad++. I am not sure why they are changing when in the code tags of this site.
|
Only a few are wrong....
<script type=”text/javascript”>
return new ActiveXObject(“Microsoft.XMLHTTP”);
document.getElementById(“testForm”).style.display = “none”;
<a href=”#” onclick=”submitFormWithAjax();”>
Quote:
Originally Posted by mrmodest
What do you mean by name and id? I am new to this. Should it be name instead of id?
|
yes ...
form elements usually need names.
this uses the form element name ...
document.testForm.ebox.value
Quote:
Originally Posted by mrmodest
Where is the } that should not exist?
|
Code:
<script type=”text/javascript”>
// function create GetXmlHttpObject
function GetXmlHttpObject(){
if (window.XMLHttpRequest){
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject){
// code for IE6, IE5
return new ActiveXObject(“Microsoft.XMLHTTP”);
}
return null;
}
function submitFormWithAjax(){
var myAjaxGetrequest = new GetXmlHttpObject();
var t2lName=document.testForm.namebox.value;
var t2lEmail=document.testForm.ebox.value;
var t2lAddress=document.testForm.addbox.value;
var t2lPhone=document.testForm.phnbox.value;
var parameters = "name=" + encodeURIComponent(t2lName) + "&email=" +encodeURIComponent(t2lEmail) + "&address=" + encodeURIComponent(t2lAddress)+ "&phone=" +encodeURIComponent(t2lPhone);
myAjaxGetrequest.open("GET", "thewebsite.com" + parameters, false);
myAjaxGetrequest.send( );
document.getElementById("result").innerHTML=myAjaxGetrequest.responseText;
document.getElementById(“testForm”).style.display = “none”;
//cbuxquiz.heroku.com?
}
}
</script>
also here you are using id to access the
element but the form tag has a name ...
document.getElementById(“testForm”).style.display = “none”;