Reputation: 3442
with the use of <a>
tag, i can put like:
<a href="include/sendemail.php?id_user=<?= $_GET['id_user'];?>" onclick="return confirm('Are you sure want to send an email?');" >Send Email</a>
and how do apply that code to button :
<input type="button" onclick="return confirm('Are you sure want to send an email?');" value="Send Email" >
Upvotes: 2
Views: 4911
Reputation: 23023
If you would like achieve your goal with only a little change, try something like this:
<input type="button" onclick="if(confirm('Are you sure want to send an email?')) { document.location.href = 'include/sendemail.php?id_user='; } " value="Send Email" />
Upvotes: 2
Reputation: 43235
<input type="button" onclick="return myFunc();" value="Send Email" >
<script>
function myFunc()
{
var flag = confirm('Are you sure want to send an email?');
if(flag)
document.location.href = "include/sendemail.php?id_user=<?= $_GET['id_user'];?>" ;
else
return false;
}
Upvotes: 2
Reputation: 318488
<form action="include/sendemail.php" method="GET">
<input type="hidden" name="id_user" value="<?php echo intval($_GET['id_user']); ?>" />
<input type="button" onclick="return confirm('Are you sure want to send an email?');" value="Send Email" />
</form>
You could also use onsubmit
of the <form>
tag.
Upvotes: 0
Reputation: 887285
Buttons are not hyperlinks.
To make a button navigate to a different page, you can write location = 'URL';
in the click
handler.
Upvotes: 0