Page 2 of 2

Posted: Thu Aug 03, 2006 5:05 am
by JayBird

Code: Select all

<input type=\"button\" value=\"Delete Record\" onClick="checkit('formname')">

Posted: Thu Aug 03, 2006 5:15 am
by mohson
Ok,

Ive put

Code: Select all

<?php include "dyn.header"; ?>
<!-- Please don't remove these comments -->
<!-- Content Start -->

<script language="javascript"> 
function checkit(form) 
{ 
    var answer = confirm('Are you sure?'); 

    if (answer) { 
        form.submit(); 
    } else { 
        return false; 
    } 
} 
</script>
This at the top of my page and Ive changed the delete cde to this:

Code: Select all

echo "<form action=\"editorganisations.html?org_id=$org_id\" method=\"post\">
<input type=\"hidden\" name=\"action\" value=\"Delete Record\">
<input type=\"button\" value=\"Delete Record\" onClick="checkit('formname')"> 
</form>
BUt nothing happens

Posted: Thu Aug 03, 2006 5:22 am
by JayBird
Come on, think about it.

Hmmm...what is your form called :hint:

Posted: Thu Aug 03, 2006 5:25 am
by JayBird
infact, i would probably do it like this

Code: Select all

<script language="javascript"> 
function checkit() 
{ 
    var answer = confirm('Are you sure?'); 

    if (answer) { 
        return true;
    } else { 
        return false; 
    } 
} 
</script> 

Code: Select all

echo "<form action=\"editorganisations.html?org_id=$org_id\" method=\"post\">
<input type=\"hidden\" name=\"action\" value=\"Delete Record\">
<input type=\"submit\" value=\"Delete Record\" onclick=\"checkit()\">
</form>

Posted: Thu Aug 03, 2006 5:29 am
by jmut
Is it something complicated or as simple as:

Code: Select all

<form action='deleterecord.php' method='POST'>
 <input type='hidden' name='id' value='123' />
 <input type='submit' name='delete' value='Delete record' onclick="if(confirm('Are you sure?')) return true; else return false;" />
</form>
Edit: Sorry ..didn't see there is second page. both examples should work.

Posted: Thu Aug 03, 2006 5:57 am
by mohson
Ok Ive done it using Pimps method but one problem when you click cancel it still deletes the record?

Why is

Posted: Thu Aug 03, 2006 6:07 am
by Benjamin
put return in front of the function name. ie onclick="return function()"

Posted: Thu Aug 03, 2006 6:35 am
by mohson
sorry where do I put that?

Posted: Thu Aug 03, 2006 7:24 am
by jmut
mohson wrote:sorry where do I put that?


....
<input type="hidden" name="action" value="Delete Record">
<input type="submit" value="Delete Record" onclick="javascript: return checkit();">
</form>