Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables from form values not working with ASP / VBscript 1

Status
Not open for further replies.
Feb 2, 2005
54
US
I have a form using the following code.

Code:
<form action="default.asp" method="post" name="login">
<input name="User" type="text" size="20"/>
<input name="Pass" type="password" size="20"/>

What I need default.asp to do is capture those form inputs and store them in a variable that I can call within a VBScript section of the Remote Desktop Web Connection. I can get the variables to display correctly so I know that they are being passed properly, but they are not being used later on when I call them. Below is a snipit of the code I am using within default.asp.

Code:
<%@ language="vbscript" %>
<%
    'Create Variables for User and Pass from Form
    Dim User
	Dim Pass
    'Read the search form variable. 
    User = CStr(Request("User"))
	Pass = CStr(Request("Pass"))
%>

<script language="vbscript">
sub BtnConnect
MsRdpClient.UserName = User
MsRdpClient.Domain = ""
MsRdpClient.AdvancedSettings.ClearTextPassword= Pass

I apologize in that I am very new to all of this and that this might be a very simple question.


 
It looks like you are trying to use server-side and client-side variables together. This is not possible. However, there are other workarounds for you. You can create temporary HTML variables in your default.asp page that are set to the values you need and then reference them directly within your default.asp file. You could also write it directly in ASP. I'm not sure which would be better, but you can play with them to see what may work best for you. Examples of what I'm talking about are below (these are only examples, you'll have to modify them as you need for yourself).
Code:
<%  [COLOR=green]'Default.asp[/color]
Response.write "<form name='frmLogin' action='default.asp' method='post'>"
response.write "<input type='hidden' name='User' value='" & cStr("User") & "'>
response.write "<input type='hidden' name='Pass' value='" & cStr("Pass") & "'>
response.write "</form>
[COLOR=green]'This will create a form on your default.asp page that will allow you to now reference the values in your client side script. [/color]
%>

<script language="vbscript">
sub BtnConnect
MsRdpClient.UserName = frmLogin.User.value
MsRdpClient.Domain = ""
MsRdpClient.AdvancedSettings.ClearTextPassword= frmLogin.Pass.value

The second example:

Code:
[COLOR=green]'This will allow you to write your client side script and pull the values directly from ASP.  It's not the best solution, but it may work for you.  Bear in mind that you will need to keep this where you currently have it (after you have declared your ASP "User" and "Pass" variables).[/color]
Response.write "<script language=""vbscript"">"
response.write "sub BtnConnect"
response.write "MsRdpClient.UserName = " & User 
response.write "MsRdpClient.Domain = """""
response.write "MsRdpClient.AdvancedSettings.ClearTextPassword=" & Pass


------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Great! You explained it perfectly and the sample code was enough to get me going. Here is the actual code that I used in order to get it working. I will have to modify it even more to do some password validation but this was my biggest concern and I can handle it from here. Thanks again....

Code:
<%
Response.write "<form name='frmLogin' action='default.asp' method='post'>"
response.write "<input type='hidden' name='User' value='" & CStr(Request("User")) & "'>"
response.write "<input type='hidden' name='Pass' value='" & CStr(Request("Pass")) & "'>"
response.write "</form>"
%>

MsRdpClient.UserName = frmLogin.User.value
MsRdpClient.Domain = ""
MsRdpClient.AdvancedSettings.ClearTextPassword= frmLogin.Pass.value
 
I'm glad that helped you. Sometimes, we just need a slightly different perspective. [thumbsup]

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top