469,887 Members | 1,206 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,887 developers. It's quick & easy.

erroe while updating XML file using ASP and javascript

Hi,
I need to update an XML file using ASP and javascript/vbscript.

But this is not working.It is showing the error – ‘document’ is not defined –in the line
str1=document.getElementById('D1').value;

Kindly someone can help me regarding this.


Here is my Code using ASP and javascript:
[Note: here I have not written the HTML in detail as there are many controls in the page.]

<% @LANGUAGE="javascript" %>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Update</title>
<script language="javascript">

<%
function update_test()

{
xmlDoc = Server.CreateObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load (Server.MapPath("config_data.xml"));
%>
confirm('Do you want to update this value');

str1=document.getElementById('D1').value;
str2=document.getElementById('D2').value;
str3=document.getElementById('T8').value;
str_script=document.getElementById('T11').value;
str_path=document.getElementById('T12').value;
str_suit=document.getElementById('T13').value;
str_dir=document.getElementById('T14').value;

x1= xmlDoc.getElementsByTagName(str1)[0].getElementsByTagName('tests');
for (i=0;i<x1.length;i++)
{
if((x1.item(i).attributes[0].value)==str2)
{
old_value=x1.item(i).attributes[0].name;
x1[i].setAttribute(old_value,str3);
x2=x1.item(i).getElementsByTagName("prerequisitesc ript")
for (l=0;l<x2.length;l++)
{
x2[l].text=str_script;
}
x3=x1.item(i).getElementsByTagName("acbuildpath")
if(x3[0].hasChildNodes())
{
x3[0].text=str_path;
}
x4=x1.item(i).getElementsByTagName("testsuitscript ")

if(x4[0].hasChildNodes())
{
x4[0].text=str_suit;
}
x5=x1.item(i).getElementsByTagName("testdir")

if(x5[0].hasChildNodes())
{
x5[0].text=str_dir;
}

}
}

<%
xmlDoc.save("config_data.xml");
%>

alert("Data Updated");
<%
}
%>

</script>
<body>
<form method="POST" action="--WEBBOT-SELF--" onSubmit="">

<img border="0" id="img6" src="images/button50.gif" height="20" width="100" alt="Update" fp-title="Update" onclick=<%update_test()%>></a></p>
</form>
</body>
</html>

Thanks……….
Aug 15 '09 #1
0 1600

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by billrdio | last post: by
1 post views Thread by TGriffith | last post: by
16 posts views Thread by Stevo | last post: by
2 posts views Thread by =?Utf-8?B?TUNN?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.