Onclick return function malfunctioning in IE

V

vimal

Hi guys,

<input class="btn" type="submit" name="terminate" value="Terminate"
onclick="return check_proc_sel()" />

i have returned false from check_proc_sel() but still the form's
submit event is called
It works properly in Firefox but not in IE.
solutions???

regards,
vimal
 
S

SAM

vimal a écrit :
Hi guys,

<input class="btn" type="submit" name="terminate" value="Terminate"
onclick="return check_proc_sel()" />

i have returned false from check_proc_sel() but still the form's
submit event is called
It works properly in Firefox but not in IE.
solutions???

Je ne suis pas devin !

Without knowing what dooes the function : no solution !
If something in the function stops it in error whith IE, probably
'false' is not returned ?

always to prefer the solution in form tag

<form onsubmit="return check_proc_sel()" blah >
....
<input type=submit class="btn" value="Terminate">
</form>
 
E

Evertjan.

SAM wrote on 24 jul 2008 in comp.lang.javascript:
<input type=submit class="btn" value="Terminate">

OT, but according to Dr Who it should be:

<form action='
'>
<input type=submit class="Dalek" value="Exterminate">
</form>
 
V

vimal

The function is as follows:

function check_proc_sel(){
var field = document.procs.process_checked;
var count = 0;
for (i=0;i&lt;field.length;i++){
if (field.checked==true){
count += 1;
}
}
if (count == 0){
alert("No process selected to Terminate or Kill")
return false;
}
else{
return true;
}
}

vimal
 
S

SAM

vimal a écrit :
The function is as follows:

Try :

function check_proc_sel(){
var field = document.procs.process_checked;
if(typeof field == 'undefined')
{
alert('no such field');
return false;
}
var count = 0;
for (i=0, n = field.length; i<n; i++)
{
if (field.checked) count++;
}
if (count == 0)
{
alert("No process selected to Terminate or Kill")
field.focus();
return false;
}
return true;
}


And use the onsubmit in tag form
instead of onclick in submit button
 
V

vimal

vimal a écrit :
The function is as follows:

Try :

function check_proc_sel(){
var field = document.procs.process_checked;
if(typeof field == 'undefined')
{
alert('no such field');
return false;
}
var count = 0;
for (i=0, n = field.length; i<n; i++)
{
if (field.checked) count++;
}
if (count == 0)
{
alert("No process selected to Terminate or Kill")
field.focus();
return false;
}
return true;
}

And use the onsubmit in tag form
instead of onclick in submit button


IE script debugger shows error in the following line

line ===> field.focus();
error ===> object doesn't support this property

vimal
 
S

SAM

vimal a écrit :
function check_proc_sel(){
var field = document.procs.process_checked;
if(typeof field == 'undefined')
{
alert('no such field');
return false;
}
var count = 0;
for (i=0, n = field.length; i<n; i++)
{
if (field.checked) count++;
}
if (count == 0)
{
alert("No process selected to Terminate or Kill")
field.focus();
return false;
}
return true;
}

IE script debugger shows error in the following line

line ===> field.focus();
error ===> object doesn't support this property

doesn't understand that IE didn't display the message
"not such field" ? !

is(are) this(these) 'process_checked' is(are) checkbox(es) ?

try :

alert ("No process selected to Terminate or Kill");
if(field[0]) field[0].focus();
return false;
 
T

Thomas 'PointedEars' Lahn

var field = document.forms["procs"].elements["process_checked"];

if (!field)

(You are dealing with a host object here.)
window.alert(...);

for (var i = field.length; i--;)

(Order does not matter here, and this is faster.)
{
if (field.checked) count++;
}
if (count == 0)
{
alert("No process selected to Terminate or Kill")
field.focus();
[...]

[...]
IE script debugger shows error in the following line

line ===> field.focus();
error ===> object doesn't support this property


Suppose count == 0, then no checkbox was selected. In that case you are
trying to focus *the checkbox group*, which is bound to fail. You need to
remove this statement or change it to field[0].focus() and the like. As
always, you should feature-test host object's method son runtime before you
call them.

Please trim your quotes as you can see here.


PointedEars
 
B

beegee

Hi guys,

<input class="btn" type="submit" name="terminate" value="Terminate"
onclick="return check_proc_sel()" />

i have returned false from check_proc_sel() but still the form's
submit event is called
It works properly in Firefox but not in IE.
solutions???

regards,
vimal

Is it neccessary to do it this way?

How about:
<form ..... onsubmit="check_proc_sel()">
...
</form>

<script type='text/javascript'>
function check_proc_sel()
{
I'm checkin but I don't like what I find so...
return false;
}
</script>

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top