php - Javascript confirm box redirect to dynamic URL -
this trying do, not work. solutions?
window.location = "delete.php?case=<?php echo $case; ?>"
to handle redirect when confirming, need sure use right quotes @ right time , in case of link, make sure cancel default link behaviour:
inline:
<a href="#" onclick="if (confirm('delete?')) window.location='delete.php?case=<?php echo $case; ?>'; return false">delete using script</a>
inline using plain js function:
function deleteit(id) { if (confirm('delete?')) { window.location='delete.php?case='+id; } return false; }
using
<a href="#" onclick="return deleteit('<?php echo $case; ?>')">delete using script</a>
unobtrusively using plain js function:
window.onload=function() { document.getelementbyid("<?php echo $case; ?>").onclick=function() { if (confirm('delete?')) { window.location='delete.php?case='+this.id; } return false; } }
using
<a href="#" id="<?php echo $case; ?>">delete using script</a>
unobtrusively using jquery:
$(function() { $("#<?php echo $case; ?>").on)"click",function() { if (confirm('delete?')) { window.location='delete.php?case='+this.id; } return false; }); });
using
<a href="#" id="<?php echo $case; ?>">delete using script</a>
Comments
Post a Comment