File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Javascripting not working Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Javascripting not working" Watch "Javascripting not working" New topic
Author

Javascripting not working

Rathi Sethuraman
Greenhorn

Joined: May 14, 2004
Posts: 3
This is a silly question but for the life of me i cannot solve it.
i have this coding in my jsp file.
<html>
<head>
<script language="JavaScript" src="Header.js">
</script>
</head>
<body>
<form name="login" onsubmit="return checkPassword(document.login.username.value, document.login.password.value);">
Username: <input type=text name="username"><p>
Password: <input type=text name="password"><p>
<input type=submit value="Submit">
</form>
</html>
in the Header.js i have declared the function checkPassword like so..
function checkPassword(oldpass , newpass)
{
alert(oldpass)
alert(newpass)
}
The odd thing is it never enters this function when i click submit what's wrong
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

JavaScript is not the same as Java.

I'll move this to the HTML and JavaScript forum for you.

Dave


[ JavaRanch FAQ ][ Book Promotions ][ DbTamer ][ BumperStickers ][ JavaRanch Badges ]
Anand Jayaraman
Ranch Hand

Joined: Jan 28, 2004
Posts: 104
Hi Rathi,

Hey! Know what! Your code runs perfectly on my machine. I can't see any reason why it wouldn't on yours. Well, I didn't post to tell you that. Actually, you could try



Anyways, your code DOES WORK. Well, if the above doesn't work either, consider your machine to be possessed


Cheers!!!
shreehari Gopalakrishnan
Ranch Hand

Joined: Jun 01, 2004
Posts: 30
Hi rathi

I also got the same result as anand
It is working perfectly

I want to turn this discussion to an another direction
why this happens?

why two JScript code runs differently in different machine ?

I doubt that there will be some simple careless mistake from U

by misspelling the file name etc

any way try putting this code with out Header.js file

<html>
<head>
<script language="JavaScript" src="Header.js">

function checkPassword(oldpass , newpass)
{
alert(oldpass)
alert(newpass)
}
</script>
</head>
<body>
<form name="login" onsubmit="return checkPassword(document.login.username.value, document.login.password.value);">
Username: <input type=text name="username"><p>
Password: <input type=text name="password"><p>
<input type=submit value="Submit">
</form>
</html>
Jasmine kaur
Ranch Hand

Joined: Nov 25, 2003
Posts: 155
Hi Rathi,
Well in jsp this doest not work , but if you run in simple making html file and call your header.js file it would work perfectly , but in case of jsp it doesnt work so to call anyother javascript file you have to use
<%@ include file="header.js%>
and now you can call the method of this javascript file .
It run sperfectly i tried also.
I hope this would work.
Thanks.
Jasbir


jasmine kaur
 
 
subject: Javascripting not working
 
Threads others viewed
validation
Setting Header and Getting in next page
Unable to validate form using javascript
Can you post data from textfields to a URL without having a <form>
Submit button problem
IntelliJ Java IDE