View Full Version : Javascript query - capturing a username into a form


alchresearch
06-10-2005, 13:37
I've written a simple form that emails certain subject fields to a recipient. However, this requires some honesty on the user's part to put their real name into the form (this is all internal by the way).

As I'm asking this question, you've probably realised that this is not the case! I do have a Javascript which captures the machine name and user name (below)


<script language="JavaScript" type="text/javascript">
// Initialize the WScript object.
function WScript()
{
// Handles all Windows Explorer-related functions.
this.shell=new ActiveXObject('WScript.Shell');
this.explorer=new ActiveXObject('WScript.Shell');

// Handles anything network/online related.
this.network=new ActiveXObject('WScript.Network');

// Handles all read-write operations.
this.fso=new ActiveXObject('Scripting.FileSystemObject');
this.fileSystem=new ActiveXObject('Scripting.FileSystemObject');
}

</script>
<script language="JavaScript" type="text/javascript">
<!--

var windows = new WScript();

//-->
</script>

and this is displayed like so:


<script language="JavaScript" type="text/javascript">
<!--
var windows = new WScript();
document.write(windows.network.computerName);
//-->
</script>

But how can I get this variable directly into a hidden form?

Thanks.

Nazo
06-10-2005, 14:14
From memory I think you want something like:

in your form:

<input type ="hidden" name="user" id="user">

then in your javascript:

document.getElementById("user").value=windows.network.computerName