473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Login - javascript execution

I am trying to create a simple login routine, and am failing completely, I have tried to simplify the test and still no luck.

HTML
<form method="post" action="" >
<div>
<input type="text" name="field1"/>
<input type="password" name="field2"/>
<input type="button" name="submit" value="Click" onclick="javascript:test(field1.value,field2.value )"/>
</div>
</form>

SCRIPT
<script type="javascript">
<!--
function test(field1,field2)
{
echo "in the test<br>";
alert ("i am in the code");
return;
}
//-->
</script>

ERROR
Microsoft JScript runtime error: Object expected
<input type="button" name="submit" value="Click" onclick="javascript:test(field1.value,field2.value )"/>
This part of the line is highlighted when in debug:
javascript:test(field1.value,fi



I know I have probably done something really simple, please help!
Dec 13 '07 #1
8 1775
Markus
6,050 Expert 4TB
try changing
Expand|Select|Wrap|Line Numbers
  1. <input type="button" name="submit" value="Click" onclick="javascript:test(field1.value,field2.value)"/>
  2.  
to
Expand|Select|Wrap|Line Numbers
  1. <input type="button" name="submit" value="Click" onclick="test(field1.value,field2.value)"/>
  2.  
please remember to use CODE tags when posting - it makes provided code easier to read.

And also, this is the PHP forum, not javascript.
Dec 13 '07 #2
I am trying to create a simple login routine, and am failing completely, I have tried to simplify the test and still no luck. This code is in a php page!

HTML
[HTML]<form method="post" action="" >
<div>
<input type="text" name="field1"/>
<input type="password" name="field2"/>
<input type="button" name="submit" value="Click" onclick="javascript:test(field1.value,field2.value )"/>
</div>
</form>
[/HTML]
SCRIPT
Expand|Select|Wrap|Line Numbers
  1. <script type="javascript">
  2. <!--
  3. function test(field1,field2)
  4. {
  5. echo "in the test<br>";
  6. alert ("i am in the code");
  7. return;
  8. }
  9. //-->
  10. </script>
  11.  
ERROR
Microsoft JScript runtime error: Object expected
<input type="button" name="submit" value="Click" onclick="javascript:test(field1.value,field2.value )"/>
This part of the line is highlighted when in debug:
javascript:test(field1.value,fi

I have tried all of the following onclick commands and still the same error
onclick="javascript:test(field1.value,field2.value )"
onclick="javascript:test(field1,field2)"
onclick="test(field1.value,field2.value)"
onclick="test(field1,field2)"

I know I have probably done something really simple, please help!
Dec 13 '07 #3
Mark,

This does not work either. I have republished the problem in the correct area!
Dec 13 '07 #4
clai83
41
I've been creating a login script as well. And actually I finished it in firefox, and it worked fine with safari, and opera, but not IE.

It would be great if someone were to post the solution to this.

This particular error also comes up in Zend Studio when doing a debug session.

IE strikes again -_-
Dec 13 '07 #5
acoder
16,027 Expert Mod 8TB
I am trying to create a simple login routine, and am failing completely, I have tried to simplify the test and still no luck. This code is in a php page!
You have an echo statement inside a JavaScript statement. Firstly, that should appear in PHP tags. Secondly, it needs to be valid JavaScript, e.g. an alert statement.
Dec 14 '07 #6
acoder
16,027 Expert Mod 8TB
I've been creating a login script as well. And actually I finished it in firefox, and it worked fine with safari, and opera, but not IE.
What error did you get in IE? Post your code.
Dec 14 '07 #7
clai83
41
What error did you get in IE? Post your code.
I have similar code to kerriejones (the javascript part not the PHP).

[HTML]
<input
class="shortInputField"
id="username"
name="username"
type="text"
title="<?php echo $html['usertitle']; ?>"
maxlength="40"
value="<?php if (isset($clean['username'])) { echo $clean['username'];} else {echo "";}?>"
tabindex="1"
onfocus="this.hasFocus=true; <?php echo $html['fieldcheck']; ?>;"
onkeyup="<?php echo $html['fieldcheck']; ?>"
onblur="this.hasFocus=false; <?php echo $html['fieldcheck']; ?>;"
/>
[/HTML]

The problem I'm having is the $html['fieldcheck'] variable. This variable will either be

[PHP]
$html['fieldcheck'] = "fieldCheck('japanese');";
$html['fieldcheck'] = "fieldCheck('english')";
[/PHP]

I get the exact same error kerriejones does, where

Microsoft JScript runtime error: Object expected

The function fieldCheck is fairly lengthy but here is the basic structure

Expand|Select|Wrap|Line Numbers
  1. function fieldCheck(language) {
  2.       //set some vars and regex stuff
  3.      var  username =  document.login.username; 
  4.      //for example
  5.  
  6.      if (username.value.length === 0) {
  7.            if (language == 'english') {
  8.                 //print a english error in paragraph innerHTML
  9.            }
  10.            else {
  11.                 //print a japanese error in paragraph innerHTML
  12.            }
  13.     }
  14.  
  15. }
  16.  
I'm a complete newb to javascript. It may be simple, I just can't seem to find it. I'm not sure why there is a JScript runtime error, am I not telling the browser correctly that I'm using javascript. I used <script type="text/javascript" src="something.js" ></script> in the head element. Should I be using something else? Or is there something about IE javascript handling I don't know about. (probably is)

Hopefully I've given enough information
Dec 14 '07 #8
acoder
16,027 Expert Mod 8TB
I have similar code to kerriejones (the javascript part not the PHP).

[HTML]
<input
class="shortInputField"
id="username"
name="username"
type="text"
title="<?php echo $html['usertitle']; ?>"
maxlength="40"
value="<?php if (isset($clean['username'])) { echo $clean['username'];} else {echo "";}?>"
tabindex="1"
onfocus="this.hasFocus=true; <?php echo $html['fieldcheck']; ?>;"
onkeyup="<?php echo $html['fieldcheck']; ?>"
onblur="this.hasFocus=false; <?php echo $html['fieldcheck']; ?>;"
/>
[/HTML]

The problem I'm having is the $html['fieldcheck'] variable. This variable will either be

[PHP]
$html['fieldcheck'] = "fieldCheck('japanese');";
$html['fieldcheck'] = "fieldCheck('english')";
[/PHP]
Maybe it's the double semi-colon. Which line does the error occur on?
Dec 17 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: koolyio | last post by:
Hey, could you please tell me what is wrong with my login script. I just started learning php. CODE: login.php <? session_start(); header("Cache-Control: private"); ?>
6
by: Andy Fish | last post by:
Hi, I want to use an anchor tag to invoke some javascript and I've read that it's bad form to use <a href="javascript:foo()"> I've read endless usenet posts and hint sites on the net, they all...
4
by: rrober07 | last post by:
Hello, My Setup is I have a Web Server machine(Devweb01), Database SQL Machine(Devsql01), a Client Machine(local machine) I have configured the SQL machine as follows: 1) Added local Aspnet...
0
by: nedk | last post by:
I am getting the following error when attempting to login to a site where I am trying to use Membership. Does anyone know why I am getting this error and how to fix it. Thanks in advance. -Ned ...
2
by: ARK | last post by:
Database: DB2 AIX V8.* Question: I want to be able to get the 'Client login ID' aka 'Execution ID' (as opposed to the authid or application_id) for the current connection within a stored...
0
by: Larry Bertolini | last post by:
While trying to help a developer troubleshoot a performance problem, I have discovered something that strikes me as odd. When I run a particular query, using a non-privileged login that has...
10
by: =?Utf-8?B?UmljaGFyZCBCeXNvdXRo?= | last post by:
Hi In my app I have a SplashScreen, a login form and a main form. On launching the app, I'd like to show the SplashScreen while reading config files and attempting a database connection. I show...
10
by: John Passaniti | last post by:
(Note: This is not the same message I posted a week or so ago. The problem that prevented my previous attempt to work was a silly error in the template system I was using. This is a problem...
4
by: MartinRinehart | last post by:
I've written a short article explaining closures in JavaScript. It's at: http://www.martinrinehart.com/articles/javascript-closures.html I think I've understood. I look forward to your...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.