zend link button element in controller - php

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;?>">

Related

How to place two submit button in a view page with different action in a controller using codeigniter version 3

I have home_c controller, home_m model and home_v view page in code igniter application folder. My view home_v page contains following code.
<?php
echo form_open('home_c/save');?>
Name:<input type="text" name="name" value="">
<input type="submit" name="sub" value="Save">
<?php echo form_close();?>
<?php
echo form_open('home_c/view');?>
<input type="submit" name="view" value="View">
<?php echo form_close();?>
My problem is that, I could not execute function view() in controller home_c. But I can execute same function by placing instead of the view button. I don't know what is the real issue behind this. Anybody please help me to solve this issue.
If you want different action for each button, use the a href = base_url 'Controller/Method'.. Like this one, button type = "button" a href=" base_url() . 'Controller/Method'
if($this->input->post('sub')=='Save'){
$this->your_model->add($data);
}
if($this->input->post('view')=='View'){
$this->load->view('view',$data);
}
Change like this and check

How to add value of $user variable to button name?

im trying to show the user's name $user on a button but i cant figure how to do it:
here's some of the code
include ("config.php");
include ("adminchk.php"); // Check if user is admin
include ("getdir.php");
include ("lang/lang_".$lang.".php");
if (isset($uStat) and $uStat===TRUE)
{
echo $GLOBALS['l_menuWelcome'] . " " . $user."\n";
if ($admin===TRUE) echo "*";
echo "<div class='quote'>\n"; ... etc
and here's the button code :
<button type="button" class="btn btn-default" onclick="location.href='userconnect.html'" >$user</button>
thanks for your time :)
To print a PHP variable in the middle of some HTML, you need to wrap it in PHP tags and use echo. So assuming your button code comes from a PHP file, the code looks like this:
<button type="button" class="btn btn-default" onclick="location.href='userconnect.html'" >
<?php echo $user; ?>
</button>
Documentation

Wordpress submit a form, update link with form input and go to that link & link is "#"?

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>

facebox cancel event

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');

How to disable buttons/links on a page for certain condition php/html

The page is a form, in the header file there are about 6 buttons which determine the page you are one, i want to disable all but the first button if we are on the first page(first button)
Thank you
This is in a foreach loop to fill in all buttons with a different pagename:
echo '<input type="submit" name="submit" id="completeButton" class="menu' . ($page == $p ? '_selected':'') . '" value="' . $p . '">';
I guess you have a page ID somewhere
Do you loop through your buttons to create them ?
If you don't loop through them, you just have to add something like
<input type="button" <?php if ($pageId !== 1) echo 'disabled="disabled"' ?> />
Then for the second button, you test it with $pageId !== 2 and so on...
try this
<html>
<button type="button">bttn1</button>
<button type="button" disabled="disabled">bttn2</button>
<button type="button" disabled="disabled">bttn3</button>
<button type="button" disabled="disabled">bttn4</button>
<button type="button" disabled="disabled">bttn5</button>
<button type="button" disabled="disabled">bttn6</button>
</html>
You can do it in several ways but 6 buttons seems confusing and unnecessary for me.
Why don't you create one button labeled 'Next step'?
I suggest using session to keep track of where the user is. You could easily check this by checking a session variable:
<?php
/**
* Checks to see if a session key exists and returns the
* corresponding value otherwise returns false
*
* #param <String> $key
* #return <String/Boolean>
*/
function session($key) {
if(isset($_SESSION[$key])) {
return $_SESSION[$key];
}
return false;
}
if(!session('curr_page')) {
// redirect to first page and set the curr page to one
$_SESSION['curr_page'] = 1;
header('Location: path/to/your/page.php');
}
$curr_page = session('curr_page');
// now you can use a series of if statements to disable
// the other buttons
?>
<?php if($curr_page > 0): ?>
// display first button etc
<?php endif; ?>
<?php if($curr_page > 1): ?>
// display second button etc
<?php endif; ?>
<?php if($curr_page > 1): ?>
// display second button etc
<?php endif; ?>
I hope this helps.

Categories