View Single Post
  #1  
Old 12-05-2016, 03:20 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 68,465
Dinocanid is on a distinguished road
Default Buttons with different actions?

I'm pretty confused on how to use buttons. I know how to make them appear but I don't know how to make them do anything. I know I could use code similar to the many forms around the site like so:
PHP Code:
if($mysidia->input->post("submit")){
            
$document->setTitle($this->lang->rename_success_title);
            
$document->add($image);
            
$message "<br>{$this->lang->rename_success}{$mysidia->input->post("adoptname")}
                        You can now manage 
{$mysidia->input->post("adoptname")} on the";
            
$document->addLangvar($message);
            
$document->add(new Link("myadopts/manage/{$adopt->getAdoptID()}""My Adopts Page"));
            
$adopt->setHealth($addHealth"update");
                        if (
$health 100){$adopt->setHealth(100"update");
            
$document->add(new Comment("<br></br>{$adopt->getName()} has full health!"));
            }
            
            return;
        }
        
        
$document->setTitle($this->lang->rename.$adopt->getName());
        
$document->add($image);
        
$document->addLangvar("<br />{$this->lang->rename_default}{$adopt->getName()}{$this->lang->rename_details}<br />");
        
        
$renameForm = new FormBuilder("renameform""""post");
        
$renameForm->buildTextField("adoptname")->buildButton("Rename Adopt""submit""submit");
        
$document->add($renameForm); 
(The health part was from me testing my health mod btw, so you can ignore that part)
But what if I wanted two buttons on the same page that do different things when clicked? For example, I want to have two different buttons, one that lowers a value when clicked and another that raises a value. Would I have to have two forms?

EDIT: I figured it out. I had to use two forms
__________________

Last edited by Dinocanid; 12-05-2016 at 06:26 PM.
Reply With Quote