473,385 Members | 1,661 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,385 software developers and data experts.

Browser 'form' differences?

I'm new to trying to use javascript, so I'm probably doing something
wrong.
This code works with MSIE, but not with Firefox. And advice greatly
appreciated.

In HTML page "head" section, I have this line:
<script language="javascript" type="text/javascript"
src="lib/form.js"></script>

In the "body", this is the FORM:
<form>
<input type="button" value="Log in to Upload" onClick="login()"> <br>
<input type="button" value="Forgot Password" onClick="sendpw()">
<input type=text name="pwd" size="48"> Enter registered email address
and click "Forgot Password"
</form>

The file "form.js" contains:
function login() {
vMsg="lib/login.php";
window.location=vMsg;
}
function sendpw() {
pw=document.getElementById('pwd').value;
if (pw == '') {
alert("Enter a valid email address");
}
else {
vMsg="lib/check.php?USERPW="+pw;
window.location=vMsg;
}
}

Thanks in advance,
Evan

May 10 '06 #1
3 1206
ASM
ev*********@worldnet.att.net a écrit :
I'm new to trying to use javascript, so I'm probably doing something
wrong.
This code works with MSIE, but not with Firefox. [...] <input type="button" value="Forgot Password" onClick="sendpw()">
<input type=text name="pwd" size="48"> Enter registered email address
and click "Forgot Password"
<input id="pwd" name="pwd" type=text size="48">

with an ID, because
function sendpw() {
here you want to get an object (or element) by its ID
get element by ID
pw=document.getElementById('pwd').value;
With IE it works with name because IE uses to aproximate whatever he touchs
if (pw == '') {
alert("Enter a valid email address");
}
else {
vMsg="lib/check.php?USERPW="+pw;
window.location=vMsg;
}
}


--
Stephane Moriaux et son [moins] vieux Mac
May 10 '06 #2
ev*********@worldnet.att.net wrote:
I'm new to trying to use javascript, so I'm probably doing
something wrong.
This code works with MSIE, but not with Firefox. And
advice greatly appreciated.
The _only_ part of this that should be implemented with javascript is
the validation of the non-empty password (which should be done with an -
onsubmit - handler on the form element). The rest should be done with a
normal HTML form (real submit buttons) and PHP (in your case) on the
server. Part of learning javascript is learning when not to use it.

<snip> <input type=text name="pwd" size="48"> Enter ... <snip> function sendpw() {
pw=document.getElementById('pwd').value;

<snip> ^^^^^^^^^^^^^^

Your HTML contains no elements with the ID attribute "pwd". IE is in
error in returning elements with the NAME attribute, but no other
browsers repeat that fault. See:-

<URL: http://jibbering.com/faq/faq_notes/form_access.html >

Richard.
May 10 '06 #3
Thanks! for your responses, and for your advice. I appreciate your
time.
Regards,
Evan

ev*********@worldnet.att.net wrote:
I'm new to trying to use javascript, so I'm probably doing something
wrong.
This code works with MSIE, but not with Firefox. And advice greatly
appreciated.

In HTML page "head" section, I have this line:
<script language="javascript" type="text/javascript"
src="lib/form.js"></script>

In the "body", this is the FORM:
<form>
<input type="button" value="Log in to Upload" onClick="login()"> <br>
<input type="button" value="Forgot Password" onClick="sendpw()">
<input type=text name="pwd" size="48"> Enter registered email address
and click "Forgot Password"
</form>

The file "form.js" contains:
function login() {
vMsg="lib/login.php";
window.location=vMsg;
}
function sendpw() {
pw=document.getElementById('pwd').value;
if (pw == '') {
alert("Enter a valid email address");
}
else {
vMsg="lib/check.php?USERPW="+pw;
window.location=vMsg;
}
}

Thanks in advance,
Evan


May 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

56
by: Don G | last post by:
I currently have IE6 and Firefox installed on my machine, and I switch between the two when testing web sites I am working on. It is my understanding that IE5 is still pretty common. Is this...
5
by: Foreman | last post by:
Using ASPFileUpload (http://support.microsoft.com/default.aspx?scid=kb;en-us;299692) and works for IE6 and FireFox but not Safari. Thanks in advance for your assistance.
11
by: James | last post by:
I wasn't sure where to post this so I'm sorry if this is the wrong place. But I would like to know what some of the differences are between client-side and server-side browser sniffing. I'm aware...
2
by: Thomas Storm | last post by:
Is there a method in JavaScript that will detect and return the coordinates of a mouse click? For example, if someone clicked the mouse within the browser window, the method would return...
12
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical...
17
by: lawrence | last post by:
How is it possible that the question "How do I detect which browser the user has" is missing from this FAQ: http://www.faqts.com/knowledge_base/index.phtml/fid/125 and is only here on this...
4
by: MS | last post by:
Just a general question here re VBA. Can anyone explain the differences between "!" and "." when refering to a control? eg Me!TxtBox and Me.TxtBox. What is difference between "+" and "&"...
5
by: jeremy | last post by:
I have an ASP.Net 2.0 application running on Windows Server 2003. The application displays properly in Internet Explorer, however, when I use a browser control embedded in a .net form, I get an...
19
by: Coward 9 | last post by:
HI, I saw in an example hello.aspx, there is a <form tagbeing used like <form runat="server> I search all html tag references and could NOT find "runat" attributes for <formtag. which...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.