Javascript hard coding vs passing var problem

Last post 05-20-2008 1:13 PM by Senthil kumar K. 1 replies.

Sort Posts:

  • Javascript hard coding vs passing var problem

    05-14-2008, 12:01 PM
    • Loading...
    • TaffyLewis
    • Joined on 06-26-2003, 7:35 AM
    • Augusta, GA
    • Posts 62

    I'm having  a problem with a Javascript function

    hard coded it works (some Ip is my company's ip address)
    var net = new ActiveXObject("wscript.network");
    net.MapNetworkDrive("K:", "\\\\some ip\\WSAProjects");

    But, what I'm doing is getting the values for the drive and path from a web form, when I do that, I get a errors, no matter what I do.  I get either  "Wrong number of arguments" error  or  "wrong number of arguments or invalid property assignment"

    this is an example of how I get the values, when I put them in an alert, their coming across just fine.

    var drive = cell[1].innerHTML + ':';
    var path = cell[3].innerHTML;

    now the var drive and path have what I need, but no matter how I pass them to the function, it does not work.  I've tried:

    net.MapNetworkDrive(drive,path);
    net.MapNetworkDrive(drive + ', ' + path);
    var str = '"' + drive + '"' + " , " + '"' + path + '"';
    net.MapNetworkDrive(str);

    These don't works, but hard coding does work.

    Can someone help me here?

    Taffy

     

    Alway take some time for fun!
  • Re: Javascript hard coding vs passing var problem

    05-20-2008, 1:13 PM

    net.MapNetworkDrive(drive, path); is the correct way.

     But getting values using innerHTML is not a write way, because there my be possibilities of spaces at end, and it may be dncoded to  .

    add alert statements, before you pass the value to the method.

    window.alert(drive);

    window.alert(path);

    This is the best way debugging.

    With Best Regards,

    Senthil kumar K.

    [Tip : A clue is hidden in every error message]
Page 1 of 1 (2 items)