473,749 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

window.event.re turnValue = false in firefox

(I'm not a programer, I have learned enough php to build my cms, but
that doesn't make me coding guru, so please excuse me if I'm asking
something trivail...)

well, I have one upload form where I want my users to choose category
for their picture. they are alowed to upload more then one picture at
time. and there is a problem. I have to use
<select name="name[$num]">
for my php script, so I have added id to the select tag
<select id="katSelector $num" name="name[$num"]>
so I can test if there is the same number of choosen category as the
number od pictures chossen for upload:
(whole php/javascript function:)

function validateCat()
{
<?
$uvjeti = "";
for ($num=0; $num<$brsl; $num++) {
$element = "$uvjeti(docume nt.iduslike.kat Selector$num.va lue == 0)";
if ($num < ($brsl - 1)) {
$uvjeti = "$element || ";
}
else {
$uvjeti = "$element";
}
}
echo"if ($uvjeti) {\n alert( \"just alert message\" );\n
window.event.re turnValue = false;\n t}";
?>
}

in a case of 2 photos to upload, above functions create following code
in my page:

<script type="text/javascript">
<!--
function validateCat()
{
if ((document.idus like.katSelecto r0.value == 0) ||
(document.idusl ike.katSelector 1.value == 0)) {
alert( "just alert message" );
window.event.re turnValue = false;
}
}
//-->
</script>

and that works in Safari on my Mac, that works in IE on friends PC, but
that doesn't work on Firefox on any platform: I'm getting alert mesage,
but my upload function gets executed.

I have found that FF (and NN) doesn't understud:
window.event.re turnValue = false;

It is now second day as I'm trying to find solution, but my knowlage of
js (and other variations) is so limited that I just can't go anmy
further...

please, can anyone help me?
here is whole form for case with just one photo to upload:
(trimed some irelevant lines)
(as seen in browser!)

<form name="iduslike" enctype="multip art/form-data" action=""
method="POST">
<input type="hidden" name="MAX_FILE_ SIZE" value="153600">
<input name="userfile[0]" type="file">
<input type="text" name="slika_naz iv[0]" size="20">
<select id="katSelector 0" name="slika_kat egorija[0]">
<option value="0">IZABE RI KATEGORIJU!</option>
<option value="1">kateg orija 1</option>
<option value="2">kateg orija 2</option>
<option value="3">kateg orija 3</option>
</select>
<input type="submit" value="upload" onClick="valida teCat()">
<input type="reset">
</form>

--
Ja NE
http://fotozine.org/?omen=janimir
--
Dec 7 '05 #1
9 17878
Ja NE <hi****@mail.zz > wrote:
function validateCat()
{
if ((document.idus like.katSelecto r0.value == 0) ||
(document.idusl ike.katSelector 1.value == 0)) {
alert( "just alert message" ); try { window.event.re turnValue = false; } catch( dummy ) {}
return false; // Tell non-IE to ignore event }
}


I don't claim that's the most elegant solution, but it's effective.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Dec 7 '05 #2
On 07/12/2005 15:03, Ja NE wrote:
I have to use
<select name="name[$num]">
for my php script, so I have added id to the select tag
<select id="katSelector $num" name="name[$num"]>
There's no need to introduce an id attribute. Just use square bracket
notation:

formObject.elem ents['name[' + num + ']']

The value of the variable, num, can either be constant (zero to match
'name[0]'), or varied in a loop.

[snip]
<script type="text/javascript">
<!--
Omit the SGML comment. It's unnecessary.
function validateCat()
{
if ((document.idus like.katSelecto r0.value == 0) ||
(document.idusl ike.katSelector 1.value == 0)) {
alert( "just alert message" );
window.event.re turnValue = false;
}
}


Expanding on my suggestion above, it would be better to generate code
that resembles:

function validateCat(for m) {
for(var i = 0; i < XX; ++i) {
var category = form.elements['name[' + i + ']'];

if('0' == category.option s[category.select edIndex].value) {
alert('...');
return false;
}
}
return true;
}

where XX is the number of SELECT elements, and seems to be $brsl in your
PHP code.

There are a few changes in that code, but two are more significant than
the others.

1. The validateCat function has an argument, form. This is a
reference to the form being validated. This value can either
be supplied from the onsubmit handler:

<form ... onsubmit="retur n validateCat(thi s);">

or an onclick handler on a submit button, but the former is
better, in my opinion.
2. Rather than assigning a value to the returnValue property of
an event object, the cod above will simply return that
value.

Your code will fail in Fx and others for two reasons. The
first is that most browsers do not have a global event
object, so window.event will evaluate to undefined.
Secondly, the returnValue property is a proprietary feature.
In other browsers returning a value from an event listener
is equivalent, and is supported by IE, too.

Hope that helps,
Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Dec 7 '05 #3
Christopher Benson-Manica wrote:
Ja NE <hi****@mail.zz > wrote:
function validateCat()
{
if ((document.idus like.katSelecto r0.value == 0) ||
(document.idusl ike.katSelector 1.value == 0)) {
alert( "just alert message" );

try {
window.event.re turnValue = false;

} catch( dummy ) {}
return false; // Tell non-IE to ignore event


So IE is not IE ...
}
}


I don't claim that's the most elegant solution, but it's effective.


Effective to break where Exception handling is not supported? Yes.
Effective to submit the form anyway? Yes.
PointedEars
Dec 8 '05 #4
Thomas 'PointedEars' Lahn <Po*********@we b.de> wrote:
Effective to break where Exception handling is not supported? Yes.
What UA with any currency doesn't support exception handling?
Effective to submit the form anyway? Yes.


How so?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Dec 9 '05 #5
Christopher Benson-Manica wrote:
Thomas 'PointedEars' Lahn <Po*********@we b.de> wrote:
Effective to break where Exception handling is not supported? Yes.


What UA with any currency doesn't support exception handling?


I do not know what you mean by "with any currency", so I ignore that.

Exception handling (i.e. the `try' statement) is not supported by
IE/Windows (I do not know about IE/Mac) before version 5.0 (JScript
before version 5.0; current in browsers is 5.6) and Netscape before
version 6.0 (JavaScript before version 1.4; current in browsers is
1.6), for example. It has also been mentioned here that there are
mobile devices that do not support all ECMAScript 3 features of
which exception handling is one.

Furthermore, it turns out that there are different levels of support
for exception handling:

<URL:http://pointedears.de/scripts/js-version-info#try>

However, Michael has already pointed out that there is a
viable solution here without the need for exception handling
where the latter should always be the last resort.
Effective to submit the form anyway? Yes.


How so?


Because not the `submit' event of the `form' element is canceled but
the `click' event of a button is (or is not).

It should be <form ... onsubmit="retur n validateCat(thi s)"> instead
which is always reliable (client-side JS/ECMAScript support provided)
and requires no further language feature.
PointedEars
Dec 9 '05 #6
Thomas 'PointedEars' Lahn <Po*********@we b.de> wrote:
I do not know what you mean by "with any currency", so I ignore that.
Basically my point is that yes, if one wants to support absolutely
every conceivable system, one must take extreme care. However, if one
decides that supporting the infinitesimal number of users still
saddled with abysmal UA's like IE 4 and NS 4 isn't worth the extra
effort, cleaner solutions can be devised. Again, I did not claim that
the code I posted was a good idea.
Furthermore, it turns out that there are different levels of support
for exception handling: <URL:http://pointedears.de/scripts/js-version-info#try>
That resource looks to be full of useful information. However, as
long as we're debating points of pedantry, the "toggle scroll" button
has no effect in Opera, and for whatever reason the table is unusable
in the default button state in IE 6.
However, Michael has already pointed out that there is a
viable solution here without the need for exception handling
where the latter should always be the last resort.
I will keep that in mind.
It should be <form ... onsubmit="retur n validateCat(thi s)"> instead
which is always reliable (client-side JS/ECMAScript support provided)
and requires no further language feature.


I noticed that only somewhat later. You're right.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Dec 10 '05 #7
Christopher Benson-Manica wrote:
Thomas 'PointedEars' Lahn <Po*********@we b.de> wrote:
I do not know what you mean by "with any currency", so I ignore that.
Basically my point is that yes, if one wants to support absolutely
every conceivable system, one must take extreme care. However, if
one decides that supporting the infinitesimal number of users
still saddled with abysmal UA's like IE 4 and NS 4


It is impossible to call that number, but it is certainly not infinitesimal
small.
isn't worth the extra effort,
That person would probably not provide anything important, in both meanings.
cleaner solutions can be devised. Again, I did not claim that the code
I posted was a good idea.
ACK

What about

| It has also been mentioned here that there are mobile devices that do not
| support all ECMAScript 3 features of which exception handling is one.

?
Furthermore, it turns out that there are different levels of support
for exception handling:

<URL:http://pointedears.de/scripts/js-version-info#try>


That resource looks to be full of useful information.


Thanks, however I am still working on it. Any constructive information
regarding it is appreciated.
However, as long as we're debating points of pedantry,
I do not consider that to be one:
the "toggle scroll" button has no effect in Opera, and for whatever
reason the table is unusable in the default button state in IE 6.


That is strange as previous tests have shown that overflow:scroll
is supported by IE 6 (could you provide navigator.userA gent of the
browser you have tested with?). I will have to test that code again.
PointedEars
Dec 10 '05 #8
Thomas 'PointedEars' Lahn <Po*********@we b.de> wrote:
What about | It has also been mentioned here that there are mobile devices that do not
| support all ECMAScript 3 features of which exception handling is one.
I've stopped digging :-)
That is strange as previous tests have shown that overflow:scroll
is supported by IE 6 (could you provide navigator.userA gent of the
browser you have tested with?). I will have to test that code again.


Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

I also thought IE 6 recognized overflow: scroll, and I'm pretty sure
I've used it before myself. I'm not sure what might be the problem,
but in case it helps I've taken a high-resolution screenshot with my
IE version information and put it at http://ataru.gomen.org/files/ss.jpg.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Dec 11 '05 #9
Christopher Benson-Manica wrote:
Thomas 'PointedEars' Lahn <Po*********@we b.de> wrote:
That is strange as previous tests have shown that overflow:scroll
is supported by IE 6 (could you provide navigator.userA gent of the
browser you have tested with?). I will have to test that code again.


Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

I also thought IE 6 recognized overflow: scroll, and I'm pretty sure
I've used it before myself. I'm not sure what might be the problem,
but in case it helps I've taken a high-resolution screenshot with my
IE version information and put it at http://ataru.gomen.org/files/ss.jpg.


Thanks, that will help.
Regards,
PointedEars
Dec 11 '05 #10

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

Similar topics

1
5378
by: Robert Nurse | last post by:
Hi All, I've got a form which I'm trying to submit automatically when the user has entered 2 or more characters in a text imput box. Here's my set up: <SCRIPT language="JavaScript1.2"> function submitLetters(form, control) { var returnValue = true;
1
20772
by: Perttu Pulkkinen | last post by:
I have different functions that receive window.event as parameter. Functions are used like this: <input type="text" id="x" onkeypress="return onKeyCurrencyCheck(ev, 'x')" onblur ="onBlurCurrencyCheck(event, 'x')""> Works very well with IE, but window.event and maybe window.event.keycode too seems to be missing form firefox. Is there a workaround for this?
6
14907
by: rich_poppleton | last post by:
Help.... I've got a textarea where people type in a description. However for certain reasons we need to stop them typing !$*^ . I have a solution this which works fine in IE: function keypress() {
3
8521
by: Raul M. Colon | last post by:
Is possible to assign a click event to a button control in a Web form just pressing the return key? Something like windows forms where you can assign this action to a default control. For example, if I press Return, I want to fire the button_click event even when the button is not in focus. Any thoughts? Thanks! Raul
6
5406
by: Scott Lee | last post by:
I am displaying an ASP.Net generated form in a popup opened with window.showModalDialog. The form contains DropDownList controls. The first ddl is populated via databinding to a datatable, has its AutoPostBack set to true and has its SelectedIndexChanged event being handled in codebehind. The event fires as it should populating two more ddls. The problem is, the two ddls appear empty. I have used a javascript alert to look at the...
18
3349
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to the image. The desired behavior is that when the pop-up is invoked, I want the underlying window to stay put. I don't have this problem when I run the code on my local computer but I do have it when I run the code on geocities.
5
7327
by: Robert S | last post by:
I am using the following to prevent the Enter key from submitting my form (this would have undesirable results): (index.html) <body onkeydown="rejectEnter( event )"> (functions.js) function rejectEnter( oEvent ) { if ( 13 == oEvent.keyCode )
4
3758
by: Arnab das | last post by:
Below is the javascript code i am using function confirmDelete() { var returnValue = window.confirm("Deleting the current page. Continue?"); return returnValue; // var returnValue = $find('mdlPopUpExt').show();
0
9568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9389
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8257
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2218
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.