FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

problem here?

 


morfeusman
i can't seem to find the problem with this code:
Code:
<html>
<body>

<script type="text/javascript">
function checkit(pass, inputvalue) {
alert("work");
if (pass=="password")
  {
alert('correct password');
  }
}
</script>
<form name="john">
<input type="text" name="lala">
<input type="button" value="click" onclick="checkit(document.john.lala.value, "did you enter the right password?");"
</body>
</html>

i think it has to do with the arguments but i am not sure.
can anyone help me?
grinta
Code:
<html>
<body>

<script type="text/javascript">
function checkit(pass, inputvalue) {
alert("work");
if (pass=="password")
  {
alert('correct password');
  }
}
</script>
<form name="john">
<input type="text" name="lala">
<input type="button" value="click" onclick="checkit(document.john.lala.value, 'did you enter the right password?');"
</body>
</html>


nope, you used a double quote inside a double quote... the above works
Star Wars Fanatic
You also forgot the end of the input, which may have allowed it to work, but it would have caused problems eventually. This line is also where you had the double quotes inside of double quotes. You can do that, as long as you escape the quotes that are on the inside.
Code:
<input type="button" value="click" onclick="checkit(document.john.lala.value, 'did you enter the right password?');" />


Full code:
Code:
<html>
<body>

<script type="text/javascript">
function checkit(pass, inputvalue) {
alert("work");
if (pass=="password")
  {
alert('correct password');
  }
}
</script>
<form name="john">
<input type="text" name="lala" />
<input type="button" value="click" onclick="checkit(document.john.lala.value, "did you enter the right password?");" />
</form>
</body>
</html>


You also forgot to close the form, which will cause problems in the future...
Marcuzzo
don't you mean?:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Title here</title>
<script type="text/javascript">
<!--
function checkit(pass, inputvalue) {
   alert("work");
   if (pass=="password")  {
      alert('correct password');
     }
}

-->
</script>
</head>
<body>
   <div>
      <form id="john" action="">
         <p>
            <input type="text" name="lala" />
            <input type="button" value="click" onclick="checkit(document.john.lala.value, 'did you enter the right password?');" />
         </p>   
      </form>
   </div>   
</body>
</html>
halilibo
may be you can use

Code:

document.getElementByName('lala').value
     instead of
document.john.lala.value

Marcuzzo
halilibo wrote:
may be you can use

Code:

document.getElementByName('lala').value
     instead of
document.john.lala.value




there is no such function as getElementByName

you can use getElementsByTagName or getElementById, but in the last case the input element would need an ID
Related topics

URGENT!!!!
Problem With Databse, and file management.
Should I be pissed at the moderators here?
Problem with sending emails (sender address verification)
Photoshop Problem

Problem with Flash preloader
Problem
Spam problem in a guestbook
Problem with my USB ports!
Math Problem

CHMOD problem
PHP imagecreate + CSS problem.
PHP imagecreate + CSS problem.
4gb(or more) memory problem with 32-bit systems
domain
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.