By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,251 Members | 2,764 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,251 IT Pros & Developers. It's quick & easy.

Can't send activeX value to ASP using Javascript

P: n/a
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.ComputerNam
</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.Valu

--></SCRIPT></BODY></HTML>
Jul 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"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
Jul 19 '05 #2

P: n/a
Hi Joe,

Thanks for your reply.

The security issue with the activex code isn't a problem because this will
be live only within our intranet and not on machines that users will play
about with.

I'm far from an expert in this field. I've not done any ASP for a few
years, and I've never done any activeX before. I've pretty much thrown this
code together from samples...hence why theres javascript and vbscript mixed.

Anyway thanks for your code, but unfortunately it doesn't work. The
computer name is not passed through, its just an empty value. It definately
does grab it though because an output to the screen within the activex
component will show the computer name as I want.

Any suggestions?

Many thanks

Jon
"Joe Fawcett" <jo********@hotmail.com> wrote in message
news:OY*************@tk2msftngp13.phx.gbl...
"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

Jul 19 '05 #3

P: n/a
Try:

<HTML>
<HEAD>
<!-- Start of ActiveX -->
<Script language="javascript">
var oNetwork = new ActiveXObject("WScript.Network")
var sComputerName = oNetwork.ComputerName
alert(sComputerName);
</script>
<!-- End of ActiveX -->
</HEAD>
<BODY>
<FORM NAME="MyForm" ACTION="GetInfo.asp" METHOD="post"><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">
<!--
alert(sComputerName);
alert(MyForm.sComputerName.Value);
MyForm.sComputerName.Value = sComputerName;
alert(MyForm.sComputerName.Value);
-->
</SCRIPT>
</BODY>
</HTML>

What do the alert boxes tell you?

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"NewbieJon" <Ne*******@nospam.com> wrote in message
news:rN**************@newsfe3-win.server.ntli.net...
Hi Joe,

Thanks for your reply.

The security issue with the activex code isn't a problem because this will
be live only within our intranet and not on machines that users will play
about with.

I'm far from an expert in this field. I've not done any ASP for a few
years, and I've never done any activeX before. I've pretty much thrown this code together from samples...hence why theres javascript and vbscript mixed.
Anyway thanks for your code, but unfortunately it doesn't work. The
computer name is not passed through, its just an empty value. It definately does grab it though because an output to the screen within the activex
component will show the computer name as I want.

Any suggestions?

Many thanks

Jon
"Joe Fawcett" <jo********@hotmail.com> wrote in message
news:OY*************@tk2msftngp13.phx.gbl...
"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


Jul 19 '05 #4

P: n/a
Hi Mark,

Thanks for your help.

I get 4 alerts as follows in this order (My computer name is "Jon"):

1. Jon
2. Jon
3. Undefined
4. Jon

I'm getting a little lost now. Is this good, and how do I pass this to my
ASP?

Thank you.
"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:OP**************@TK2MSFTNGP11.phx.gbl...
Try:

<HTML>
<HEAD>
<!-- Start of ActiveX -->
<Script language="javascript">
var oNetwork = new ActiveXObject("WScript.Network")
var sComputerName = oNetwork.ComputerName
alert(sComputerName);
</script>
<!-- End of ActiveX -->
</HEAD>
<BODY>
<FORM NAME="MyForm" ACTION="GetInfo.asp" METHOD="post"><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">
<!--
alert(sComputerName);
alert(MyForm.sComputerName.Value);
MyForm.sComputerName.Value = sComputerName;
alert(MyForm.sComputerName.Value);
-->
</SCRIPT>
</BODY>
</HTML>

What do the alert boxes tell you?

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"NewbieJon" <Ne*******@nospam.com> wrote in message
news:rN**************@newsfe3-win.server.ntli.net...
Hi Joe,

Thanks for your reply.

The security issue with the activex code isn't a problem because this will
be live only within our intranet and not on machines that users will play about with.

I'm far from an expert in this field. I've not done any ASP for a few
years, and I've never done any activeX before. I've pretty much thrown

this
code together from samples...hence why theres javascript and vbscript

mixed.

Anyway thanks for your code, but unfortunately it doesn't work. The
computer name is not passed through, its just an empty value. It

definately
does grab it though because an output to the screen within the activex
component will show the computer name as I want.

Any suggestions?

Many thanks

Jon
"Joe Fawcett" <jo********@hotmail.com> wrote in message
news:OY*************@tk2msftngp13.phx.gbl...
"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



Jul 19 '05 #5

P: n/a
"NewbieJon" <Ne*******@nospam.com> wrote in message
news:rN**************@newsfe3-win.server.ntli.net...
Hi Joe,

Thanks for your reply.

The security issue with the activex code isn't a problem because this will
be live only within our intranet and not on machines that users will play
about with.

I'm far from an expert in this field. I've not done any ASP for a few
years, and I've never done any activeX before. I've pretty much thrown this code together from samples...hence why theres javascript and vbscript mixed.
Anyway thanks for your code, but unfortunately it doesn't work. The
computer name is not passed through, its just an empty value. It definately does grab it though because an output to the screen within the activex
component will show the computer name as I want.

Any suggestions?

Many thanks

Jon

In this line make sure value has a small 'v':
MyForm.sComputerName.value = sComputerName;
return true;

It would also be better to have your hidden field named differently from
your variable holding the computer name.

--
Joe
Jul 19 '05 #6

P: n/a
It's probably the capital "V" as the other poster mentioned.

Change it to:

alert(sComputerName);
alert(MyForm.sComputerName.value);
MyForm.sComputerName.value = sComputerName;
alert(MyForm.sComputerName.value);

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"NewbieJon" <No@spam.com> wrote in message
news:6Q*************@newsfe1-gui.server.ntli.net...
Hi Mark,

Thanks for your help.

I get 4 alerts as follows in this order (My computer name is "Jon"):

1. Jon
2. Jon
3. Undefined
4. Jon

I'm getting a little lost now. Is this good, and how do I pass this to my
ASP?

Thank you.
"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:OP**************@TK2MSFTNGP11.phx.gbl...
Try:

<HTML>
<HEAD>
<!-- Start of ActiveX -->
<Script language="javascript">
var oNetwork = new ActiveXObject("WScript.Network")
var sComputerName = oNetwork.ComputerName
alert(sComputerName);
</script>
<!-- End of ActiveX -->
</HEAD>
<BODY>
<FORM NAME="MyForm" ACTION="GetInfo.asp" METHOD="post"><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">
<!--
alert(sComputerName);
alert(MyForm.sComputerName.Value);
MyForm.sComputerName.Value = sComputerName;
alert(MyForm.sComputerName.Value);
-->
</SCRIPT>
</BODY>
</HTML>

What do the alert boxes tell you?

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"NewbieJon" <Ne*******@nospam.com> wrote in message
news:rN**************@newsfe3-win.server.ntli.net...
Hi Joe,

Thanks for your reply.

The security issue with the activex code isn't a problem because this will be live only within our intranet and not on machines that users will play about with.

I'm far from an expert in this field. I've not done any ASP for a few
years, and I've never done any activeX before. I've pretty much thrown
this
code together from samples...hence why theres javascript and vbscript mixed.

Anyway thanks for your code, but unfortunately it doesn't work. The
computer name is not passed through, its just an empty value. It

definately
does grab it though because an output to the screen within the activex
component will show the computer name as I want.

Any suggestions?

Many thanks

Jon
"Joe Fawcett" <jo********@hotmail.com> wrote in message
news:OY*************@tk2msftngp13.phx.gbl...
> "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
>
>



Jul 19 '05 #7

P: n/a
Many thanks to you both, I now have this working.
Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.