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

Fire firefox?

This is driving me simply crazy ... this simple (?) code works in Msie
but not Firefox.

function checkform ()
{
if (document.regfrms.cgbx.itm1.checked == false &&
document.regfrms.cgbx.itm2.checked == false){
alert( "You have to choose one" );
document.regfrms.cgbx.itm1.focus();
return false ;
}
return true ;
}
It checks the values of 2 radio buttons and if neither have been
pressed it alerts the user.

See this for yourselves....

http://www.morack.se/firedfox.html

So the question (before I request the British Government to make FOX
hunting compulsory) is how does firefox handle the checked status of
radio buttons..... ?

Any help and YOU are a genius...
Garry Jones
Sweden
PS, offendinfg code, enitre file...

<HTML>
<HEAD><TITLE>Test</TITLE>
</HEAD>
<BODY style="BACKGROUND: none transparent scroll repeat 0% 0%; MARGIN:
0px">
<script language="JavaScript" type="text/javascript">
function checkform ()
{
if (document.regfrms.cgbx.itm1.checked == false &&
document.regfrms.cgbx.itm2.checked == false){
alert( "You have to choose one" );
document.regfrms.cgbx.itm1.focus();
return false ;
}
return true ;
}

</script>
<FORM action="dosomething.php" method="post" name="regfrms"
onSubmit="return checkform()">
<TABLE width="600" border="1" cellspacing="0" cellpadding="2">
<tr>
<td >
<input title="This is item 1" type="radio" id="itm1" value="yes"
name="cgbx" >
Item 1
<br>
<input title="This is item 2" type="radio" id="itm2" value="yes"
name="cgbx" >
Item 2
<br>
</td></tr>
<td width="600" >
<input type="Submit" value = "Ok">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;
<input type="button" value="Not OK" onClick="history.back()">
</td>
</tr>
</table>
</form>

</BODY>
</HTML>
Sep 1 '08 #1
6 1514
GarryJones <mo****@algonet.sewrites:
This is driving me simply crazy ... this simple (?) code works in Msie
but not Firefox.

function checkform ()
{
if (document.regfrms.cgbx.itm1.checked == false &&
document.regfrms.cgbx.itm2.checked == false){
alert( "You have to choose one" );
document.regfrms.cgbx.itm1.focus();
return false ;
}
return true ;
}
Most browsers do not provide access to elements by id or forms by name
via the document.MyIdOrName short-cut. And as far as I know, your
cgbx.itm2 (where itm2 is an ID, and cgbx is the name of the radio(s))
isn't portable either (I may be wrong about *that* because this is the
first time I've ever seen the construct).

Since you're using IDs /anyway/, why not do:

if (!(document.getElementById("itm1").checked ||
document.getElementById("itm2").checked)) {
alert("You have to choose one");
return false;
}
// ...
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Sep 1 '08 #2
On 1 Sep, 12:41, Joost Diepenmaat <jo...@zeekat.nlwrote:
GarryJones <mor...@algonet.sewrites:
This is driving me simply crazy
... snip
Most browsers.......
... snip
, why not do:
Thanks. It works (of course).

"Most browsers" is the problem here.

The current stats (source Wiki) are
Msie: 78.30%
Netscape Navigator: 0.06%
Netscape/Mozilla/Firefox: 16.36%
Opera: 0.81%
Safari: 3.41%

As a homebrewer with nothing other to go I googled for an answer to my
problem and found the (msie biased) code I then used.

What I can never appreciate enough is guys like yourself who bother to
read questions from innocent newbies like myself and spend time
replying to us. You have solved a major headache for me as I found
nothing on the net to solve my problem. Giving the onset of permanant
connections to the Internet I am just so pleased that the USEnet
community still exists and continues to outweigh the online web forums
in quality and efficiency. As good to day as it was when I first
posted to the IBM Knowledge base back in the summer of 1979. (yes,
thats right, 30 years next year.....)

Thanks again, if you're ever in Sweden the beers are on me...

Garry Jones
The(?) Englishman in Sweden
Sep 1 '08 #3
GarryJones wrote:
This is driving me simply crazy ... this simple (?) code works in Msie
but not Firefox.

[snip "document.forms" query]
How often do we get versions of this query about MSIE using the
"name-shortcut" addressing and other browsers not doing?

I presume it is already in the FAQ, so perhaps it would help if we
regularly post a message in the group to the effect of "Here is where
you find the FAQ - read it before you ask a question we keep getting
asked"
Sep 2 '08 #4
The Magpie wrote:
GarryJones wrote:
>This is driving me simply crazy ... this simple (?) code works in
Msie but not Firefox.

[snip "document.forms" query]

How often do we get versions of this query about MSIE using the
"name-shortcut" addressing and other browsers not doing?

I presume it is already in the FAQ, so perhaps it would help if we
regularly post a message in the group to the effect of "Here is where
you find the FAQ - read it before you ask a question we keep getting
asked"
It is really annoying to see the same type of problem all the time. Those
people, who hava opportunity use javascript even 24/7/365 in their work and
hobbies might have difficulty to imagine the position a person, who only
occasionally use javascript. These random turists might use 3-4 other
languages fluently, but are astonishingly newbielike in javascript. FAQ is
about 70 kilobytes, and its takes at least an hour to read it thoroughly,
but
even after that it is not necessarily easy to find out that a 'name
shortcut' is
the problem.
If there are too easy questions for the experts, what about leaving them
to less-experts to answer? Thus they get experience to learn posting
javascript.
If there is a rule that every time before posting I MUST use at least
one hour to google and read various references, then ...
Sep 2 '08 #5
In comp.lang.javascript message <87************@zeekat.nl>, Mon, 1 Sep
2008 12:41:41, Joost Diepenmaat <jo***@zeekat.nlposted:
>Since you're using IDs /anyway/, why not do:

if (!(document.getElementById("itm1").checked ||
document.getElementById("itm2").checked)) {
alert("You have to choose one");
return false;
}
I'd prefer, largely because of the comment-value of "OK",

OK = document.getElementById("itm1").checked ||
document.getElementById("itm2").checked
if (!OK) alert("You have to choose at least one")
return OK

<FAQENTRYOn the need to test in both IE & non-IE, and briefly why.

To OP : If something, even something simple, does not work, simplify
further.

For example, in my js-quick.htm there is a div with ID=Divn. If I type
the word Divn into the textarea and execute it, then :
IE: Result line [object];
FF: Result line blank,
Error console "Error: Divn is not defined".

So to simplify try alert(document.regfrms.cgbx.itm1.checked) and
consider the result.

--
(c) John Stockton, nr London UK. replyYYWW merlyn demon co uk Turnpike 6.05.
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html-Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm: about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
Sep 2 '08 #6
In comp.lang.javascript message <g9*******************@news.demon.co.uk>
, Tue, 2 Sep 2008 15:56:57, The Magpie <us****@pigsinspace.co.uk>
posted:
>GarryJones wrote:
>This is driving me simply crazy ... this simple (?) code works in Msie
but not Firefox.

[snip "document.forms" query]

How often do we get versions of this query about MSIE using the
"name-shortcut" addressing and other browsers not doing?

I presume it is already in the FAQ,
One should read the FAQ before making comments on the FAQ or posting
questions or answers which the FAQ might treat (FAQ 2.3).

FAQ 4.41 provides the OP's answer. However, I have some doubts about
its "The best approach". A document is a two-dimensional tree (being
2-D, the children of each parent are ordered), and uniquely labelling
each leaf and node that needs to be referred to does not make use of
possibilities indicated by doc.frm1.IN & doc.frm2.IN. For example, my
holidays.htm has five buttons (for 5 locations) each of which generates
a complex table; the tables are data-driven for size and content, and
their variable elements are much better addressed structurally rather
than globally. Structural addressing deserves mention.
so perhaps it would help if we
regularly post a message in the group to the effect of "Here is where
you find the FAQ - read it before you ask a question we keep getting
asked"
The daily "FAQ Topic" posts are supposed also to serve that purpose; see
FAQ sec 1 para 4.

<FAQENTRYAt an early use of "FAQ" within the FAQ, the full "Frequently
Asked/Answered Questions" should be given. </FAQENTRY>

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Sep 3 '08 #7

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

Similar topics

5
by: Frowning Freezer | last post by:
I have a function in an external javascript file which I fire from an onChange event in a <SELECT> tag. Everything works fine in IE but not in Netscape/Mozilla/Opera. This is my onChange statement:...
14
by: xxbmichae1 | last post by:
I have a <select> object that i've set up an onchange event that fires in IE fine when I use the cursor up and down in the list, but If I use the cursor up and down in Firefox the event doesn't...
45
by: Pat | last post by:
its seems asp.net validation doesn't fire when using FireFox? Tested a page and it doesn't fire. It seems the javascript doesn't fire Any ideas?
1
by: mayur_hirpara | last post by:
Hi, I have a situation where I have to populate a dropdownlist using clientside javascript, select an item from it using javascript and then fire "onchange" event using javascript. For IE I am...
2
by: cgrady | last post by:
I'm working on part of a larger project, and in trying to debug one aspect, I've got a small test file to work with. The code is practically identical (all important aspects match word for word)...
5
by: ja | last post by:
hi, i need to assign onclick function to file inupt, in fire fox on windows function is executing just after click, but on mac it seems to be execut after file browse window is closed (in safari...
2
by: byrdman | last post by:
Im developing a web app in asp.net 2.0 with c#. Users upload images and I'm useing server.Mappath to put the images in a folder on the server while putting the file name in the database. My problem...
3
scubak1w1
by: scubak1w1 | last post by:
Hello, I posted this in the HTML forum, but it was suggested I post it over here as well by a moderator. I have a form that will not 'fire' in non-IE browsers?? I have poked and poked at the code...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
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: 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...
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...

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.