View Single Post
Old 07-12-2012, 06:21 PM   PM User | #8
DaveyErwin
Regular Coder

 
Join Date: Aug 2010
Posts: 806
Thanks: 12
Thanked 168 Times in 166 Posts
DaveyErwin is on a distinguished road
Quote:
Originally Posted by mrmodest View Post

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 View Post
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 View Post

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”;

Last edited by DaveyErwin; 07-12-2012 at 06:43 PM..
DaveyErwin is offline   Reply With Quote