Thread: javascript xml

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    france
    Posts
    2
    Rep Power
    0

    javascript xml


    hello,

    I search to save my xml page but "save" don't want to save.

    my xml page is :

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <contacts>
    	<contact>
    		<nom>toto</nom>
    	</contact>
    </contacts>
    and I use this html page to add "nom":

    Code:
    <html>
    <head><title>saisie des concats</title>
    
    <script language="JavaScript">
    
    function recup ()
    	{
    		
    		var doc=document.saisiecontact.nom.value;
    		if (doc=="")  
    		{	
    			alert("po de bol");
    			window.location="erreur.html";
    		}
    		if (doc!="")  
    		{	
    			confirmation();
    		} 		
    	}
    
    function confirmation()
    {
    	if(confirm("Etes-vous sur de vouloir enregistrer ce contact ? Si oui, cliquez sur ok"))
    	{
    		enr();
    	}
    	else
    	{
    		alert ("Nous n'avons donc pas enregistrer ce contact");
    	}	
    }
    
    
    
    function enr()
    {
    var doc=document.saisiecontact.nom.value;
    
    var objDOM;
    objDOM = new ActiveXObject("MSXML.DOMDocument");
    objDOM.async = false;
    objDOM.load("contacts.xml");
    
    var objContactNode;
    objContactNode = objDOM.documentElement.firstChild;
    
    var objCopyNode;
    objCopyNode = objContactNode.cloneNode(true);
    
    objCopyNode.firstChild.firstChild.nodeValue = document.saisiecontact.nom.value;
    
    var objServNode;
    objServNode = objDOM.documentElement;
    objServNode.appendChild(objCopyNode);
    
    objDOM.save("contacts.xml"); <!-- this one don't save--> 
    
    window.location="bon.html";   		
    }
    
    
    </script>
    
    </head>
    
    <body>
    	
    	<form method="post" name="saisiecontact" >
    		
    		<TABLE>
    			<TR> 
    				<TD>Nom :</TD> 
    				<TD><input type="text" name="nom" id="nom" SIZE=30 MAXLENGHT=100></TD> 
    			</TR> 
    			
    		</TABLE>
    			
    			<input value ="ajouter" type ="submit" name ="ajouter " onclick="recup()" >  
    			<input type="reset" value="Annuler"> 
    		
    	</form>
    
    
    </body>
    </html>
    Can you help me please...
    Last edited by ametisse; February 16th, 2003 at 08:08 AM.

IMN logo majestic logo threadwatch logo seochat tools logo