1

So I want to have one login, but I have 2 different forms to distinguish different functions. How do I pass the login forms between the other 2 functions.

I know javascript and vbs, not jquery.

Example:

I want the same user and pass to appy to both forms without having to make 2 seperate inputs

<%
username = Request.Form("username")
password = Request.Form("password")
%>

<input name="username" />
<input name="password" type="password" />

<form action="test.asp?f=test1" method="post">
text inputs with a submit button
</form>

<form action="test.asp?f=test2" method="post">
different inputs with another submit button
</form>
Cameron Darlington
  • 355
  • 2
  • 7
  • 14

2 Answers2

4

I haven't used ASP Classic for ages so I am not sure if this is a correct answer, but you can give it try. Since you have two buttons and you want to know which button is being clicked. Why don't you give value to each submit button and then give it the same name? For example.

<form action="test.asp" method="post">
   <input name="username" />
   <input name="password" type="password" />
   <input name='action' type="button" value="Submit One" />
   <input name='action' type="button" value="Submit Two" />
</form>

The ASP part

If Request.Form("action") = "Submit One" Then
   '' First button is clicked
Else
   '' Second button is clicked
End If
invisal
  • 11,075
  • 4
  • 33
  • 54
1

I think you're possibly over-thinking this.

I'd put the username and password inputs into a single form and have both submit buttons displayed as follows:

<form action="test.asp?f=test1" method="post">
   <input name="username" />
   <input name="password" type="password" />
   <input id="submit-1" type="button" value="Submit One" />
   <input id="submit-2" type="button" value="Submit Two" />
</form>

Then, using JavaScript I'd wire up click event handlers on each button such that when the user click either one, the form action URL querystring would be updated before submitting the form.

var button1 = document.getElementById("submit-1");        
var button2 = document.getElementById("submit-2");

b1.onclick = function() { 
  document.form.action = "test.asp?f=test1";
  document.form.submit(); 
}
b2.onclick = function() { 
  document.form.action = "test.asp?f=test2";
  document.form.submit();
}
Phil.Wheeler
  • 16,748
  • 10
  • 99
  • 155