Reputation: 719
I have a question on how to follow the link created in PHP. After the link is cliked jquery dialog is called and after clicking its OK button, code should follow the link created by PHP.
Bellow is atached part of the code.
echo "<a href='usunProdukt.php?name=".$T_nazwa."' class='confirmation'><img src='pictures/cross16.jpg' width='10' height='10' /></a>" ;
echo "</td>" ;
echo "</tr>";
}
mysqli_close($conn);
?>
<div id="dialog-message" title="Usuwanie produktu">
<p>
<span class="ui-icon ui-icon-help" style="float:left; margin:0 7px 50px 0;"></span>Czy chcesz usunąć wybrany produkt?
</p>
<p>
Naciśnij OK aby kontynuować.
</p>
</div>
<script type="text/javascript">
$("#dialog-message").hide();
$('.confirmation').on('click', function(e) {
e.preventDefault();
$("#dialog-message").dialog({
modal: true,
buttons: {
Ok: function() {
$(this).dialog("close");
//window.location.href = "glowny.php?akcja=produkty";
},
Cancel: function() {
$(this).dialog("close");
}
}
});
});
</script>
The link should be <a href='usunProdukt.php?name=".$T_nazwa."
etc.
Thanks in advance for yours help.
Upvotes: 0
Views: 28
Reputation: 719
Apokryfos posted very good code that works for me. Working code is bellow:
echo "<a href='usunProdukt.php?name=".$T_nazwa."' class='confirmation'><img src='pictures/cross16.jpg' width='10' height='10' /></a>" ;
echo "</td>" ;
echo "</tr>";
}
mysqli_close($conn);
?>
<div id="dialog-message" title="Usuwanie produktu">
<p>
<span class="ui-icon ui-icon-help" style="float:left; margin:0 7px 50px 0;"></span>Czy chcesz usunąć wybrany produkt?
</p>
<p>
Naciśnij OK aby kontynuować.
</p>
</div>
<script type="text/javascript">
$("#dialog-message").hide();
$('.confirmation').on('click', function(e) {
e.preventDefault();
$("#dialog-message").dialog({
modal: true,
buttons: {
Ok: function() {
$(this).dialog("close");
window.location.href = $('.confirmation').attr('href');
},
Cancel: function() {
$(this).dialog("close");
}
}
});
});
</script>
Thank you very much for your help.
Upvotes: 1