• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javascripting not working

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JavaScript is not the same as Java.

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

Dave
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!!
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic