"NewbieJon" <an*******@discussions.microsoft.com> wrote in message
news:14**********************************@microsof t.com...
I am attempting to send the variable "sComputerName" from my ActiveX
script to "GetInfo.asp" using javascript. (Having been advised this is the
way to get my ActiveX variable into my ASP script).
My code is below. I am getting the following error "MyForm.oNetwork.Value
is Null or is not an object". I'm struggling to diagnose what to do next.
I'd very much appreciate some help.
Many thanks.
<HTML><BODY><FORM NAME="MyForm" ACTION="GetInfo.asp"
METHOD="post" onSubmit="MyFunc()"><!-- Start of ActiveX --><Script
language="vbscript"> Set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
</script><!-- End of ActiveX --><BR>
USERNAME: <INPUT TYPE="text" NAME="Username" SIZE="20"><BR>
PASSWORD: <INPUT TYPE="password" NAME="Password" SIZE="20"><BR><INPUT
TYPE="hidden" NAME="sComputerName"><INPUT TYPE="submit"
VALUE="Submit"><INPUT TYPE="reset"><p></FORM><SCRIPT
LANGUAGE="JavaScript"><!-- function MyFunc()
{
MyForm.sComputerName.Value = MyForm.oNetwork.Value
}
--></SCRIPT></BODY></HTML>
Firstly this is not going to work unless the particualr zone that this page
is in has very low security settings. That being said you do not need to
refer to the form and you can tidy it up a bit. And instead of mixing
VBSCript and JScript why not all in one language?
<HTML>
<HEAD>
<!-- Start of ActiveX -->
<Script language="jscript">
var oNetwork = new ActiveXObject("WScript.Network")
var sComputerName = oNetwork.ComputerName
</script>
<!-- End of ActiveX -->
</HEAD>
<BODY><FORM NAME="MyForm" ACTION="GetInfo.asp"
METHOD="post" onSubmit="return MyFunc();"><BR>
USERNAME: <INPUT TYPE="text" NAME="Username" SIZE="20"><BR>
PASSWORD: <INPUT TYPE="password" NAME="Password" SIZE="20"><BR>
<INPUT TYPE="hidden" NAME="sComputerName">
<INPUT TYPE="submit" VALUE="Submit"><INPUT TYPE="reset"><p></FORM>
<SCRIPT LANGUAGE="JavaScript">
<!--
function MyFunc()
{
MyForm.sComputerName.Value = sComputerName;
return true;
}
-->
</SCRIPT>
</BODY>
</HTML>
--
Joe