Nisanth
Nisanth

Reputation: 333

how to add confirmation message before delete in php - moodle

I have a column like below.

echo '<td class="icon" align="right"><a title="'.$strdelete.'" href="TL_CORE_viewfile.php?delete='.$re->id.'"><img'.
             ' src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="'.$strdelete.'" /></a></td>';

i want to add confirmation message before delete. i am using the following but the line having error . please any one can help me.

echo '<td class="icon" align="right"><a title="'.$strdelete.'" href="TL_CORE_viewfile.php?delete='.$re->id.'"  onClick=\"javascript:return confirm('are you sure you want to delete this?');\"><img'.
             ' src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="'.$strdelete.'" /></a></td>';

Upvotes: 1

Views: 1124

Answers (1)

Vallabh Bothre
Vallabh Bothre

Reputation: 661

There is a problem with slash. Use below line,

echo '<td class="icon" align="right"><a title="'.$strdelete.'" href="TL_CORE_viewfile.php?delete='.$re->id.'"  onClick="javascript:return confirm(\'are you sure you want to delete this?\');"><img'.
             ' src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="'.$strdelete.'" /></a></td>';

Upvotes: 1

Related Questions