Connecting Tech Pros Worldwide Forums | Help | Site Map

javascript is not working in firefox

Newbie
 
Join Date: Sep 2008
Posts: 14
#1: Sep 4 '08
Hi,

The below javascript is not working in the firefox, Please help me..

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function Login(){
  3. var done=0;
  4. var username=document.login.username.value;
  5. username=username.toLowerCase();
  6. var password=document.login.password.value;
  7. password=password.toLowerCase();
  8. if (username=="adventure" && password=="adventure") { window.location="myaccount/Redeem_Game_Card.html"; done=1; }
  9. if (done==0) {
  10. document.getElementById("error_msg").style.display = "block";
  11.  }
  12. }
  13. </SCRIPT>

Newbie
 
Join Date: Sep 2008
Posts: 14
#2: Sep 4 '08

re: javascript is not working in firefox


Hi, The below javascript is not working in the firefox. Please help me..

[HTML]<script>
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="adventure" && password=="adventure") { window.location="myaccount/Redeem_Game_Card.html"; done=1; }
if (done==0) {
document.getElementById("error_msg").style.display = "block";
}
}
</SCRIPT>


<a href="#" onClick="javascript:Login()">LOGIN</a>[/HTML]
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#3: Sep 4 '08

re: javascript is not working in firefox


Hi srinathpandit! Welcome to bytes.com!

It's great to have you here!

When you post, please always keep to the Posting Guidelines and when you post code, please post it in [code] ... [/code] tags. Just look at how much nicer your code would look with them:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function Login(){
  3.    var done=0;
  4.    var username=document.login.username.value;
  5.    username=username.toLowerCase();
  6.    var password=document.login.password.value;
  7.    password=password.toLowerCase();
  8.    if (username=="adventure" && password=="adventure") {
  9.       window.location="myaccount/Redeem_Game_Card.html"; done=1; }
  10.    if (done==0) {
  11.       document.getElementById("error_msg").style.display = "block";
  12.    }
  13. }
  14. </SCRIPT>
  15.  
  16.  
  17. <a href="#" onClick="javascript:Login()">LOGIN</a>
(although I did indent it manually)

As I've seen, you've also posted your question in the Javascript / DHTML / Ajax Forum - which is the right place for it. This isn't. So in future, please post your questions only in the relevant forum.

Otherwise, I'll just wish you the best and hope you enjoy being part of bytes.com!

Greetings,
Nepomuk
Newbie
 
Join Date: Jan 2007
Posts: 28
#4: Sep 4 '08

re: javascript is not working in firefox


What error message u r getting?
U can see the error message under Tools -->Error Console

-Hussain
Newbie
 
Join Date: Sep 2008
Posts: 14
#5: Sep 4 '08

re: javascript is not working in firefox


Hi,

Thanks for reply.

I am not getting any error message, But script is working in IE but not in firefox.
The requirement is, On giving user ID and Password, onclick on submit button,
the page should go to the Redeem_Game_Card.html.

This is not working in firfox.

I checked the error Console, There is no script errors on it on some CSS issues are there.
Newbie
 
Join Date: Sep 2008
Posts: 14
#6: Sep 4 '08

re: javascript is not working in firefox


Quote:

Originally Posted by hussain123

What error message u r getting?
U can see the error message under Tools -->Error Console

-Hussain

Hi,

Thanks for reply.

I am not getting any error message, But script is working in IE but not in firefox.
The requirement is, On giving user ID and Password, onclick on submit button,
the page should go to the Redeem_Game_Card.html.

This is not working in firfox.

I checked the error Console, There is no script errors on it, only some CSS issues are there.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#7: Sep 4 '08

re: javascript is not working in firefox


Show the corresponding HTML code.
Newbie
 
Join Date: Sep 2008
Posts: 14
#8: Sep 4 '08

re: javascript is not working in firefox


Quote:

Originally Posted by acoder

Show the corresponding HTML code.


Hi,

The below code is HTML code for login page,

----------------------------------------------------------------------------
[HTML] <p class="input_title">
Email Address:<br />
<input name="username" type="text" class="input_box" />
</p>
<p class="input_title">
Password:<br />
<input name="password" type="password" class="input_box" />
</p>

<p class="checkbox"><input type="checkbox" />Remember me</p>
<span class="privacy_link"><a href="/customercare/privacypolicy.aspx">Privacy Policy</a></span>

<div class="red_btn">
<a href="#" onClick="javascript:Login()">LOGIN</a>
<div style="clear:both;"></div>
</div>[/HTML]
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#9: Sep 4 '08

re: javascript is not working in firefox


Is your form named "login"?
Newbie
 
Join Date: Sep 2008
Posts: 14
#10: Sep 4 '08

re: javascript is not working in firefox


Quote:

Originally Posted by acoder

Is your form named "login"?

yes..

<form name="login" method="post" id="aspnetForm">
Newbie
 
Join Date: Sep 2008
Posts: 14
#11: Sep 4 '08

re: javascript is not working in firefox


Quote:

Originally Posted by acoder

Is your form named "login"?

yes...

<form name="login" method="post">
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#12: Sep 4 '08

re: javascript is not working in firefox


When you say it's not working, what happens? Does it just stay on the page even if you input the correct username/password?

PS. you shouldn't have login code on the client-side.
Newbie
 
Join Date: Sep 2008
Posts: 14
#13: Sep 4 '08

re: javascript is not working in firefox


yes..
in IE it will go to Redeem_Game_Card.html page, but in Firefox it will saty in that page only and it wont show any error also, Is there any error in the code? i am confused...

Is there any other way or code for this type of requirement.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#14: Sep 4 '08

re: javascript is not working in firefox


From a cursory look, the JavaScript code seems OK.

The HTML for the link could be changed to this:
Expand|Select|Wrap|Line Numbers
  1. <a href="#" onclick="Login(); return false;">LOGIN</a>
or better still use a button:
Expand|Select|Wrap|Line Numbers
  1. <input type="button" onclick="Login()" value="LOGIN">
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#15: Sep 4 '08

re: javascript is not working in firefox


Threads merged.

Moderator.
Newbie
 
Join Date: Sep 2008
Posts: 14
#16: Sep 5 '08

re: javascript is not working in firefox


Quote:

Originally Posted by acoder

Threads merged.

Moderator.


Thank you so much, Its working (return false;). You r a genius........

Its working in both IE and Firefox.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#17: Sep 5 '08

re: javascript is not working in firefox


You're welcome. Glad to help.
Reply