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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing Variable 1

Status
Not open for further replies.

glenmac

Technical User
Jul 3, 2002
947
0
0
CA
Hi I'm not sure this is the correct forum for this question but here goes. I am passing a value from a form to an ASP page that has some javascript on it to validate a form on the same ASP page. The problem I'm having is using the value from the ASP in the Javascript.Is there a way to use an ASP variable in a javascript. Hmm sounds confusing doesn't it? well here's some of my code.
Code:
Dim MyArray(4,1),pass,nam,i,test


 pass = request.form("Password")
 nam = request.form("UserID")

 MyArray(0,1) = "john"		
 MyArray(1,1) = "mark"
 MyArray(2,1) = "jim"
 MyArray(3,1) = "doug"
 MyArray(4,1) = "tom"

 MyArray(0,0) = "john12"		
 MyArray(1,0) = "mark12"
 MyArray(2,0) = "jim123"
 MyArray(3,0) = "doug12"
 MyArray(4,0) = "thomas"


	for i = 0 to 4						
	 If MyArray(i,1) + MyArray(i,0) =  nam + pass Then	
  	  test=true
          Exit For
	 End If
	next
	
	If test = true then
	  response.write "You are successfull"

on the same page I need to use the variable nam in a javascript.

	ID1=BobForm.usrNam.value;
       if(ID1 != nam)
	{
	alert("Please input a valid username!");
	event.returnValue=false;
	BobForm.usrNam.focus()
	BobForm.usrNam.select()
	}
Hope I've explained things well enough and someone can help. It would be much appreciated.
 
glenmac, you need to go through your code and comment it and write some suedocode on what is going on there so when you go to debug it you know what is going on. you also have a bunch of syntax errors that may not cause run-time errors but are error nun the less
example
<%Language=VBScript%>
is
<%@ Language=VBScript%> and is all sense is not needed as the default is vbscript

I dare to learn more
admin@onpntwebdesigns.com
 
For anyone interested this works ticky.
Code:
<%Language=VBScript%>
<% pass = request.form(&quot;Password&quot;)
 nam = request.form(&quot;UserID&quot;)%>
<html>
<head>
<title> Password Checker</title>
<script language=&quot;Javascript&quot; >
 var nam1 = &quot;<%=nam%>&quot;;
	function ChkID(){
		ID=BobForm.UserID.value;
		if(ID != nam1){
		alert('You must enter a User Name');
   		event.returnValue=false;
		}
 
Thanks onpnt I will try and clean it up a bit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top