<form id="forma">View Template (template.php):
<table border = "1">
<tr><td>User:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="text" name="password"></td></tr>
<tr>
<td><input type="submit" id="register" name="action" value="register"></td>
<td><input type="submit" id="logon" name="action" value="logon"></td>
</tr>
</table>
</form>
<!DOCTYPE html>Javascript (forma.js):
<html>
<head>
<meta charset="utf-8">
<title><?php echo $title ?></title>
<?php echo Asset::js($script); ?>
</head>
<body>
<?php echo $form; ?>
</body>
</html>
window.onload = init;
function init()
{
var logonbutton = document.getElementById("logon");
logonbutton.onclick = HandleLogonButton;
var registerbutton = document.getElementById("register");
registerbutton.onclick = HandleRegisterButton;
}
function HandleLogonButton(e)
{
var form = document.getElementById("forma");
form.action = "logon";
form.method = "post";
form.submit();
}
function HandleRegisterButton(e)
{
var form = document.getElementById("forma");
form.action = "register";
form.method = "post";
form.submit();
}
Controller (logon.php):
public function action_index
{
$this->template->form = View::forge(''forma.php");
$this->template->title = "Form A";
$this->template->script = "forma.js";
}
public function action_register()
{
// whatever you want
}
public function action_logon()
{
// whatever you want
}
It looks like you're new here. If you want to get involved, click one of these buttons!