By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

Onclick return function malfunctioning in IE

P: n/a
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
Jul 24 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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>

--
sm
Jul 24 '08 #2

P: n/a
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='http://www.youtube.com/watch?v=c4UJiBmVEMk'>
<input type=submit class="Dalek" value="Exterminate">
</form>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 24 '08 #3

P: n/a
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[i].checked==true){
count += 1;
}
}
if (count == 0){
alert("No process selected to Terminate or Kill")
return false;
}
else{
return true;
}
}

vimal
Jul 24 '08 #4

P: n/a
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[i].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

--
sm
Jul 24 '08 #5

P: n/a
On Jul 24, 1:33 pm, SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
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[i].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

--
sm
IE script debugger shows error in the following line

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

vimal
Jul 24 '08 #6

P: n/a
SAM
vimal a écrit :
On Jul 24, 1:33 pm, SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
>>
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[i].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;

--
sm
Jul 24 '08 #7

P: n/a
On Jul 24, 3:31*am, vimal <cool.vimalsm...@gmail.comwrote:
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
Jul 25 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.