Buttons with different actions?

Forum
Last Post
Threads / Messages

Dinocanid

Member
Member
Joined
Aug 30, 2016
Messages
520
Points
18
Age
23
Location
Maryland, USA
Mysidian Dollar
43,334
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:
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:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,122
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top