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

RUNNING SCRIPT AFTER PWORD ENTERED

Status
Not open for further replies.

rry2k

Programmer
Jun 28, 2001
678
US
Hi,
I need to know how to get the jscript portion of this code to run only after a password is entered. As it stands now it runs automatically.

Thanks..Russ

<tr> <td align=&quot;right&quot; nowrap><font face=&quot;arial&quot; size=&quot;-1&quot;>SSN</font></td>
<td><input name=&quot;passwd&quot; type=&quot;password&quot; size=&quot;17&quot; maxlength=&quot;32&quot; value=&quot;&quot;></td></tr>
<tr>
<td>&nbsp;</td>
<td><input type=&quot;submit&quot; value=&quot;Sign In&quot;></td>
</tr>
</table>
<script language = &quot;JavaScript&quot;>
pass = document.form1.passwd.value
document.write(pass);
</script>
</BODY>
</html>
 
You need to put the code in a function, and call the function via onSubmit in the form tag (which you don't seem to have):
Code:
function checkLogin() {
pass = document.form1.passwd.value
document.write(pass);
}
...
<form name=&quot;myform&quot; method=&quot;post&quot; action=&quot;...&quot; onSubmit=&quot;return checkLogin()&quot;>
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
yeah.. but what would document.write() do? :)) Victor
 
Thanks.. unfortunately that didn't work. when I type in the password and hit submit I get:

file:///H:/My%20Documents/test.htm?login=test&passwd=rest
in the address window.

Russ
 
vituz: I don't know what the document.write was intended to do, but he asked how to get it to run on submission rather than on loading, and I think I answered that.

rry2k: It appears you have another problem in your code as well. Can you post more of it? Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Tracy,

I just did a new post a few minutes ago. The code is now in a function but there is another problem.

Thanks..Russ
 


<tr> <td align=&quot;right&quot; nowrap><font face=&quot;arial&quot; size=&quot;-1&quot;>Password</font></td>
<td><input name=&quot;UserId&quot; size=&quot;17&quot; maxlength=&quot;32&quot; value=&quot;jobs&quot;></td>
</tr>
<tr> <td align=&quot;right&quot; nowrap><font face=&quot;arial&quot; size=&quot;-1&quot;>SSN</font></td>
<td><input name=&quot;passwd&quot; type=&quot;password&quot; size=&quot;17&quot; maxlength=&quot;32&quot; value=&quot;2&quot;></td></tr>
<tr>
<td> </td>
<td><input type=&quot;submit&quot; value=&quot;Sign In&quot; onClick=&quot;LogIn();&quot;></td>
</tr>
</table>
</form>
<SCRIPT LANGUAGE = &quot;JavaScript&quot;>
function LogIn(){
var username = document.form1.UserId.value;
var password = document.form1.passwd.value;
var page = username;
page += password;
page += &quot;.htm&quot;;
window.location.href = page;}
</script>
</BODY>
</html>
 
When I run this I get: document.form1.userid is null or not an object.

thx Russ
 
Tracy i meant that document.write(), when putted into the function would overwrite the hole page..

but looks like Russ has another problem..

Russ, do you still have a problem?
you see, if your form is using get method then you can't put anything location.href after form submission (there would be something like page.htm?UserId=jobs&passwd=rthfd , you know..)

and about your error message:

if you get exactly what you posted here (document.form1.userid ..) then you should notice that your password field is named UserId (i tryed the code you posted here & it worked without any errors, but the way i described below)
Victor
 
Victor,
You said you got this to work with the way you described below. Can you give me the code again. I don't see it here.

Thanks alot..Russ
 
my english is bad.. i meant above i.e.
you'll get this in address bar:
page.htm?UserId=jobs&passwd=rthfd where page.htm - your form's action.. if you would use your code

but you've been answered right in other thread Victor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top