修订版 | 40497620e60ac8dfdd2237ffa44e80657613a3dd (tree) |
---|---|
时间 | 2007-08-29 01:33:14 |
作者 | henoheno <henoheno> |
Commiter | henoheno |
v2
@@ -0,0 +1,44 @@ | ||
1 | +<?php | |
2 | +// $Id: form_submit.php,v 1.1 2007-08-28 16:33:14 henoheno Exp $ | |
3 | +// | |
4 | +// Submit buttons and toggle demo | |
5 | +// | |
6 | +// [button] prev: off/on | |
7 | +// [button] write: off/on | |
8 | +// [button] help: off/on | |
9 | +// [button] cancel: off/on | |
10 | +// showhelp: off/on <= toggle with help button | |
11 | + | |
12 | +$base = basename(__FILE__); | |
13 | + | |
14 | +// State of buttons | |
15 | +$prev = isset($_POST['prev']); | |
16 | +$write = isset($_POST['write']); | |
17 | +$help = isset($_POST['help']); | |
18 | +$cancel = isset($_POST['cancel']); | |
19 | + | |
20 | +// State of status | |
21 | +$showhelp = isset($_POST['showhelp']) && $_POST['showhelp'] == 'on'; | |
22 | +if ($help) $showhelp = ! $showhelp; // Toggle | |
23 | + | |
24 | +// Render | |
25 | +$prev = $prev ? 'on' : 'off'; | |
26 | +$write = $write ? 'on' : 'off'; | |
27 | +$help = $help ? 'on' : 'off'; | |
28 | +$cancel = $cancel ? 'on' : 'off'; | |
29 | +$showhelp = $showhelp ? 'on' : 'off'; | |
30 | +echo <<< EOF | |
31 | + [button] prev: $prev</br> | |
32 | + [button] write: $write</br> | |
33 | + [button] help: $help</br> | |
34 | + [button] cancel: $cancel</br> | |
35 | + showhelp: <strong>$showhelp</strong></br> | |
36 | + <form action="$base" method="post"> | |
37 | + <input type="submit" name="prev" value="Preview" /> | |
38 | + <input type="submit" name="write" value="Write" /> | |
39 | + <input type="submit" name="help" value="Help" /> | |
40 | + <input type="submit" name="cancel" value="Cancel" /> | |
41 | + <input type="hidden" name="showhelp" value="$showhelp"> | |
42 | + </form> | |
43 | +EOF; | |
44 | +?> | |
\ No newline at end of file |