Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Session Variable

    I am working on this page. I am pulling the session variable "test" from the previous page which is a number. If they enter that number on this page I want an alert to display saying that they cannot enter there on number. Can't seem to get it to work though.




    Code:
    <%@Language=VBScript %>
    
    <%
    		test = Session("test")
    %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    
    <script language="javascript">
    	function chkForm() {
    		var test = document.frmOrder.test.value;
    		var SessionName = document.frmOrder.SessionName.value
    		
    		// Check Number
    		if (test.value =SessionName) {
    			alert('You cannot enter this number');
    			return false
    		}	
    
    	}
    </script>
    
    </head>
    <body>
    
    
    
    			
    <form name="frmOrder" method="post" action="return.asp" onSubmit="return chkForm();">
    <input type="hidden" name="SessionName" value="<%=test%>">
    
    
    
    <table bgcolor="#ffffff" border="0" width="250" cellspacing="1" cellpadding="2" class="main">
    <tr>
    <td bgcolor="#FFFFFF">Test:</td>
    <td bgcolor="#FFFFFF"><input type="text" name="test" maxlength="5" size="5"></td>
    </tr>
    </table>
    
    
    <input type="Submit" value="Continue" name="Continue"><br>
    
    
    </body>
    </html>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,316
    Thanks
    203
    Thanked 2,566 Times in 2,544 Posts
    if (test.value ==SessionName)

  • #3
    New Coder
    Join Date
    Apr 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, but it is still not working.

  • #4
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    test already point to the value...

    try

    if (test == SessionName)

  • #5
    New Coder
    Join Date
    Apr 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That did it! Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •