• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dom Form - need help

#1
[eluser]new_igniter[/eluser]
Hi All,
I am new to Ajax, and am using an example from Wrox. I am making script to parse my gmail contacts, and put them in a form, so I could then email all of them from a webpage. My question is, given the code below, how do I put this all in a form?

Code:
function init() {
    var oXmlDom = zXmlDom.createDocument();
    oXmlDom.onreadystatechange = function () {
        if (oXmlDom.readyState == 4) {
            if (oXmlDom.parseError.errorCode == 0) {
                parseBookInfo(oXmlDom);
            } else {
                var str = "An error occurred!!\n" +
                    "Description: " + oXmlDom.parseError.reason + "\n" +
                    "File: " + oXmlDom.parseError.url + "\n" +
                    "Line: " + oXmlDom.parseError.line + "\n" +
                    "Line Position: " + oXmlDom.parseError.linepos + "\n" +
                    "Source Code: " + oXmlDom.parseError.srcText;

                alert(str);
            }
        }
    };
    oXmlDom.load("contacts.xml");
}

function parseBookInfo(oXmlDom) {
    var oRoot = oXmlDom.documentElement;
    var oFragment = document.createDocumentFragment();
    
    var aContacts = oRoot.getElementsByTagName("contact");
    
    for (var i = 0; i < aContacts.length; i++) {
    
    var sName = aContacts[i].getAttribute("name");
    var sEmail = aContacts[i].getAttribute("email");
        
        var oCurrentChild = aContacts[i].firstChild;
        
        var divContainer = document.createElement("div");
        var divContent = document.createElement("div");
    
    var checkbox = document.createElement("input");
    checkbox.type = 'checkbox';
    checkbox.name = 'checkboxName';
    checkbox.class = 'publisher';
        
        var sOdd = (i % 2)?"":"-odd";
        divContainer.className = "bookContainer" + sOdd;
        
        divContent.appendChild(document.createTextNode("Name:" + sName + " Email:" + sEmail));
        divContent.className = "bookContent";

    divContent.appendChild(checkbox);
        divContainer.appendChild(divContent);

        oFragment.appendChild(divContainer);
    }
document.body.appendChild(oFragment);

}

onload = init;


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.