Im using facebox for delete data (conformation) from MySQL. i like to know how to use a cancel button in the window. when the user click cancel facebox have to unload.
Here is the code im using in facebox.
Are You Sure You Want To Delete This URL?
<?php
include ('../db.php');
$id = $_GET['id'];
if (isset($id))
{
$query = "DELETE * FROM posts WHERE post_id='$id'";
}?>
<br/>
<br/>
<?php
echo '<a href="index.php?del='.$id.'" class="button" >Yes</a>';
echo '<a href="#" class="button" >Cancel</a>';
?>
what is the code i have to use in cancel button? thanks in advance.
Link to facebox : http://defunkt.io/facebox/
jQuery(document).trigger('close.facebox');
Related
I am not able to reload the php page after a certain button is pressed. That is there is no change until I reload the page by myself. The php script is:
<?php
// Initialize the session
session_start();
if (($_SESSION['ShowGenerated'] == 'hidden'))
{
$class = 'hidden';
}
else if (($_SESSION['ShowGenerated'] == 'visible'))
{
$class = 'show';
}
?>
<html>
<head>
....
<td><button id="pdf" name="Change" class="btn btn-primary"><i class="change-a"" aria-hidden="true"></i>Click Here</button></td>
...
On clicking "Click here" button, Change.php is called where $_SESSION['ShowGenerated'] value is generated. How do I load the current page or a URL to show a change?
EDIT: Instead of reloading the whole page, can I only reload to check if the $_Session has changed in the html page?
Try to put tag inside :
<button id="pdf" name="Change" class="btn btn-primary"><i class="change-a"" aria-hidden="true"></i>Click Here</button>
like this
DISCLAIMER: I am aware of SQL Injection, I am getting the function done first.
My delete from button does not seem to remove my row in my SQL table
products-one-time.php
This is the output of my foreach, the numbers below the delete button are the groupids, just to show they are unique.
this is the code for the delete button, it redirects to clinics_buttons.vc.php on click.
<a href="clinics_buttons.vc.php<?php echo '?delete-coupongroup='.$rowCouponGroup['groupid']; ?>" onclick="return confirm('Delete this group?');">
<button class="btn btn-danger btn-sm full_width" data-toggle="modal">
<i class="fa fa-edit"></i>DELETE
</button>
</a>
<?php echo $rowCouponGroup['groupid']; ?>
clinics_buttons.vc.php
<?php
session_start();
$routePath = "../";
require_once($routePath . "_config/db.php");
$dbConfig = new config_db();
$db = $dbConfig->init();
$delete_coupongroup = $_GET['delete-coupongroup'];
if (isset($_GET['delete-coupongroup'])) {
$stmt = $db->prepare("DELETE FROM `product_onetime` WHERE groupid = $delete_coupongroup");
$stmt->execute();
header('Location: ' . $_SERVER['HTTP_REFERER']);
}
?>
this is the product_onetime table
What I see is that my code seems to look like they are connected, but the delete button does not work. I tried to manually do the SQL in phpmyadmin, for example:
DELETE FROM `product_onetime` WHERE groupid = 5
Doing it manually works, but the php/sql does not. Would like some input.
My guess is that the file clinics_buttons.vc.php is not executed at all, because the code we see in the question is inside a <form>. In this case, the button behavior overrides the link behavior and the browser will submit the form instead of following the link.
You should be able to see that in the network tab of your development tools in your browser.
As a quick fix, change the button from a submit button into a push button:
<button type="button" class="btn btn-danger btn-sm full_width" data-toggle="modal">
<i class="fa fa-edit"></i>DELETE
</button>
A better solution would be not to use a button at all. Just make the link look like a button by using CSS styling. Or alternatively, remove the code from outside the outer form tag and give it its own form using clinics_buttons.vc.php as the form action.
I have a button that updates the query, after which I want a popup to appear.
I have used it like this:
<input type="submit" name="details" value="Details"/>
if(isset($_POST['details']))
{
// update function;
call a popup;
}
I don't want to use popup as
<button id="popup" onclick="div_show()">Popup</button>`
Or
<a href="#openModal" id="btn">
I want it as isset(..) , Is it possible? If yes how should I call a simple popup having a message and 2 buttons? (I don't want to use alert, prompt, confirm boxes , It should be a popup).
Please help.
If you are making the pop-up with java-script, you can do it like this :
<?php
if(isset($_POST['details']))
{
// update function;
echo '<script type="text/javascript">Call_PopUp(); </script>';
}
?>
or even a popup with html (iFrame)
<?php
if(isset($_POST['details']))
{
// update function;
echo '<iframe> Pop-Up here </iframe>';
}
?>
You can echo javascript code with windows.open like this:
<?php
if(isset($_POST['details']))
{
// update function;
echo "<script type='text/javascript'>var url = 'http://www.google.com'; window.open(url,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=1076,height=768,directories=no,location=no'); </script>";
}
?>
The problem with popup windows is that are blocked by all modern browser, can you evaluate modal popup instead of popup windows.
This code is a form that results in a link being created with variable $ui.
<form method="post" name="form" onsubmit="#">
Name search:
<input id="ui" type="text" name="ui" />
<input type="submit" class="Submit" value="submit" />
</form>
Then the variable $ui is used to set the value of the data-filter attribute. When you click the link (after the form submits) it goes to "#" which performs a sorting/listing function and reloads the page without refreshing.
<?php if(isset($_POST["ui"]))
{
$ui = $_POST["ui"];
}
$Filterclass = strtoupper(str_replace(" ", "-", $ui));
?>
<a href="#" id="gallery_filter"
data-filter=".<?php echo $Filterclass; ?>">
<?php echo strtoupper($ui); ?></a>
Right now, the form submits and then the link is created, then you can click on it.
It works as-is, but I'd like to have the 'submit' button just open that link, the one with newly updated data-filter attribute.
I would ask this is Wordpress.exchange but I think is too advanced.
I won't write the whole process but modify your existing code as below(assuming jquery is already loaded)
<?php if(isset($_POST["ui"]))
{
$ui = $_POST["ui"];
echo '<script type="text/javascript">
jQuery(document).ready(function(e){
jQuery("#gallery_filter").click();
});
</script>';
}
$Filterclass = strtoupper(str_replace(" ", "-", $ui));
?>
<a href="#" id="gallery_filter"
data-filter=".<?php echo $Filterclass; ?>">
<?php echo strtoupper($ui); ?></a>
I have this button in my controller and trying to echo it back to the user in my view phtml but its seems not to be returning the element.
Button
$button = new Zend_Form_Element_button('button');
$button->setAttrib('id', 'B!');
$button->setLabel('Previous');
$button->setAttrib('onClick', "parent.location='" . Zend_Controller_Front::getInstance()->getBaseUrl() .'/../..' ."'");
$this->view->button = $button;
in my view
<?php echo $this->button; ?>
Your code work in my application.
If you just want a button, you can do something like that:
In your Controller :
$this->view->location = "parent.location='" . Zend_Controller_Front::getInstance()->getBaseUrl() .'/../..' . "'";
In the view
<input id="B" type="button" value="Previous" onClick="<?php echo $this->location;?>">