<html>
<head>
<script type="text/javascript">

function getpr(txt2){
alert("I'm in");
document.write(txt2);
}


function message()
{
var doc = new ActiveXObject("Word.Application"); // creates the word object
doc.Visible=false; // doesn't display Word window
doc.Documents.Open("C:\\Users\\vinay\\Desktop\\HTMLPages\\test\\pr.txt"); // specify path to 
document
//copy the content from my word document and throw it into my variable
txt = doc.Documents("C:\\Users\\vinay\\Desktop\\HTMLPages\\test\\pr.txt").Content; 
prnumber=txt;
//alert("PR number is Set to :" + prnumber + "!");
document.write(prnumber);
doc.quit(0); // quit word (very important or you'll quickly chew up memory!)

getpr(prnumber);
}

</script>
</head>

<body onload="message()">
</body>
</html>

========================
Above script getpr() function is not working it is printing
"Undefined"
but document.write(prnumber); is printing

Your function prints the variable passed to it, and you pass it the value of doc.Documents("C:\\Users\\vinay\\Desktop\\HTMLPages\\test\\pr.txt").Content; I would imagine that's returning a null or undef value. Also, be careful with document.write in the head, best to use innerHTML to set content of existing elements. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.