Delete confirmation

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
merlin6b
Forum Newbie
Posts: 4
Joined: Tue Aug 15, 2006 2:49 pm

Delete confirmation

Post by merlin6b »

Hello.
I have a button which call a JavaScript function:

Code: Select all

<input type="submit" name="delete" value="Delete" onClick="return confirmSubmit()"
the JavaScript function :

Code: Select all

function confirmSubmit()
{
var agree=confirm("Are you sure you wish to continue?");
if (agree)
    return true ;
else
    return false ;
}
This is a delete confirmation. And work great !

On same page a I have more checkbox :

Code: Select all

<input type="checkbox" name=\"list[]\" value="{$row['id']}" /></td>";
In PHP I verify with:

Code: Select all

if (isset($_POST['list'])
if one or more checkbox selected.

I want to call the JavaScript function "Are you sure you wish to continue?" if one checkbox or more selected. If no checkbox selected I want to show : "Nothing selected" and don't call JavaScript function.

My page now call the JavaScript function with or without checkbox selected.

I appreciate any help!
I don't have much knowledge with JavaScript.

Thank you !
matt1019
Forum Contributor
Posts: 172
Joined: Thu Jul 06, 2006 6:41 pm

Re: Delete confirmation

Post by matt1019 »

merlin6b wrote:Hello.
I have a button which call a JavaScript function:

Code: Select all

<input type="submit" name="delete" value="Delete" onClick="return confirmSubmit()"
the JavaScript function :

Code: Select all

function confirmSubmit()
{
var agree=confirm("Are you sure you wish to continue?");
if (agree)
    return true ;
else
    return false ;
}
This is a delete confirmation. And work great !

On same page a I have more checkbox :

Code: Select all

<input type="checkbox" name="list[]" value="{$row['id']}" /></td>";
In PHP I verify with:

Code: Select all

if (isset($_POST['list'])
if one or more checkbox selected.

I want to call the JavaScript function "Are you sure you wish to continue?" if one checkbox or more selected. If no checkbox selected I want to show : "Nothing selected" and don't call JavaScript function.

My page now call the JavaScript function with or without checkbox selected.

I appreciate any help!
I don't have much knowledge with JavaScript.

Thank you !
Hi merlin6b,

THIS IS NOT A SOLUTION... but I just noticed a small "style" error.... well, more like a warning:

Make sure your "onClick" is "onclick" (all lower case letter) on the line below

Code: Select all

<input type="submit" name="delete" value="Delete" onClick="return confirmSubmit()"

-Matt
Post Reply