Pass parameters between Javascript and ASP

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Feb 2006
Posts: 13
Reputation: chan karan is an unknown quantity at this point 
Solved Threads: 0
chan karan chan karan is offline Offline
Newbie Poster

Pass parameters between Javascript and ASP

 
0
  #1
Feb 28th, 2006
Can anyone help me to solve the problem, i want to pass the parameters between the javascript and asp.

[html]<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
<!--
function startWord(par_1)
{
var oShell = new ActiveXObject("Shell.Application");
var commandtoRun="C:\\Karan\\Automation.exe";
oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
}
//-->
</script>
</head>
<body>
<form>
<input type="text" name="par_1" value="123">
<input type="button" value="Click me!" onclick="startWord(par_1)">
</form>
</body>
</html>[/html]
it's only open the vb.exe file, but how can i pass the parameters to this exe??

thank you for helping me~~~
Last edited by cscgal; May 4th, 2006 at 10:43 am. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Pass parameters between Javascript and ASP

 
0
  #2
Mar 1st, 2006
Please use the forum's CODE tags when posting.

JavaScript runs on the client. ASP runs on the server. You cannot "pass" variables between them, per se.

The only time ASP runs is when a REQUEST is sent to the web server, either a GET or a POST.

The way you send values to an ASP form is by adding a QueryString to your GET Requests, or by populating form values for your POST Requests (or, "form submits").
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 13
Reputation: chan karan is an unknown quantity at this point 
Solved Threads: 0
chan karan chan karan is offline Offline
Newbie Poster

Re: Pass parameters between Javascript and ASP

 
0
  #3
Mar 1st, 2006
Sorry for asking the wrong question.
Base on the above code, i can call the vb.exe program. Can i pass the parameters from javascript to vb.exe program???
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Pass parameters between Javascript and ASP

 
0
  #4
Mar 1st, 2006
I see. Well, you're passing in a value to the function, correct? Is that value you want to "pass" to the activeX object? I see you're executing the method with "commandParms", but you're never setting "commandParms" equal to anything. Should it contain the value you pass to the JavaScript function?

Okay, I'm going to assume that you want commandParms = "123".

<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
<!--
function startWord(x)
  {
commandParms = document.getElementById(x).value;
   var oShell = new ActiveXObject("Shell.Application");
    var commandtoRun="C:\\Karan\\Automation.exe";
oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
  }
  //-->
</script>
</head>
<body>
<form>
<input type="text" name="par_1" value="123">
<input type="button" value="Click me!" onclick="startWord('par_1')">
</form>
</body>
</html>
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 13
Reputation: chan karan is an unknown quantity at this point 
Solved Threads: 0
chan karan chan karan is offline Offline
Newbie Poster

Re: Pass parameters between Javascript and ASP

 
0
  #5
Mar 2nd, 2006
The error came out after added the "commandParms = document.getElementById(x).value;"
is the server not read this sentence??
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Pass parameters between Javascript and ASP

 
0
  #6
Mar 2nd, 2006
No, the server wouldn't process that... it's JavaScript, which would run on the client.

Change name="par_1" in the input text element to id="par_1" .
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 13
Reputation: chan karan is an unknown quantity at this point 
Solved Threads: 0
chan karan chan karan is offline Offline
Newbie Poster

Re: Pass parameters between Javascript and ASP

 
0
  #7
Mar 2nd, 2006
Thank you for your help.

I use the alert sentence to check the value on getelelment, but the value is "NULL".

do it mean the value can't pass to the function???
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Pass parameters between Javascript and ASP

 
0
  #8
Mar 2nd, 2006
I assure you this works. I have no idea what "getelement" means, sorry.

Here's the most simplified test version I can make for you:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function startWord(x)
  5. {
  6. var commandParms = document.getElementById(x).value;
  7. alert(commandParms);
  8. }
  9. </script>
  10. </head>
  11. <body>
  12. <form>
  13. <input id="txt" type="text" value="123" />
  14. <input id="btn" type="button" value="Click" onclick="startWord('txt')" />
  15. </form>
  16. </body>
  17. </html>
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 13
Reputation: chan karan is an unknown quantity at this point 
Solved Threads: 0
chan karan chan karan is offline Offline
Newbie Poster

Re: Pass parameters between Javascript and ASP

 
0
  #9
Mar 2nd, 2006
Thx a lot , i success la, thank you very much~~

if i want to pass two parameters, am i need to add one more text for another parameter??
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Pass parameters between Javascript and ASP

 
0
  #10
Mar 2nd, 2006
That's completely up to you. You have enough now to learn the mechanism and finish it on your own.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum


Views: 22111 | Replies: 10
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC