9
9
10
10
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
11
11
<script type="text/javascript" src="jquery.maxsubmit.js"></script>
12
+
13
+ <!-- Here the application could pass in a translated message suitable for the language of the end user -->
12
14
<script type="text/javascript">
13
15
jQuery(document).ready(function($) {
14
16
$('form#form1').maxSubmit({
19
21
});
20
22
});
21
23
</script>
24
+
25
+ <!-- Some fancy stuff for the demo -->
26
+ <script type="text/javascript">
27
+ jQuery(document).ready(function($) {
28
+ /* Toggle the enabled state on some form items */
29
+ $('.text_label, .radio_label, .select_label').click(function() {
30
+ return $(this).siblings('input, select, textarea').each(function(){
31
+ this.disabled = !this.disabled;
32
+ });
33
+ });
34
+ });
35
+ </script>
36
+
37
+ <style type="text/css">
38
+ .text_label, .radio_label, .select_label, .doc_label {cursor: pointer; border-bottom: green dotted 1px;}
39
+ </style>
22
40
</head>
23
41
24
42
<?php
43
+ // Read any submitted data to go back into the form.
25
44
$ input = array (
26
45
'text1 ' => 'Text 1 ' ,
27
46
'text2 ' => 'Text 2 ' ,
47
+ 'textarea1 ' => "A nice \nstory. " ,
28
48
'checkbox1 ' => 'on ' ,
29
49
'checkbox2 ' => '' ,
30
50
);
31
51
32
52
foreach ($ input as $ key => $ value ) {
33
- $ input [$ key ] = (isset ($ _POST [$ key ]) ? $ _POST [$ key ] : '' );
53
+ $ input [$ key ] = (isset ($ _POST [$ key ]) ? htmlspecialchars ( $ _POST [$ key ]) : $ input [ $ key ] );
34
54
}
35
55
36
56
$ input = array_merge (
@@ -88,7 +108,7 @@ function getFormSubmissionLimit($default = false)
88
108
<?php if (!empty ($ _POST )) : ?>
89
109
<p style="border-radius: 4px; border: 2px solid #ff3333; padding: 1em; background-color: #fdeaaa">
90
110
Thank you for posting some stuff!
91
- On a real application you may have lost some data by doing so .
111
+ On a real application you may have lost some data by ignoring the warning .
92
112
</p>
93
113
<?php endif ; ?>
94
114
@@ -97,35 +117,48 @@ function getFormSubmissionLimit($default = false)
97
117
For these tests, we will set the limit to 2, so the confirm message is always shown.
98
118
</p>
99
119
120
+ <p>
121
+ Clicking the labels of <span class="doc_label">the form items like this</span> will disable those items, so they are not submitted.
122
+ </p>
123
+
100
124
<form method="post" id="form1">
101
125
<h2>Mandatory form items: will count as one submitted parameter each</h2>
102
126
103
127
<p>
104
128
<input type="text" name="text1" value="<?php echo $ input ['text1 ' ]; ?> " />
129
+ <span class="text_label" title="Click to toggle toggle the enabled state">(counts as one parameter)</span>
105
130
</p>
106
131
107
132
<p>
108
133
<input type="text" name="text2" value="<?php echo $ input ['text2 ' ]; ?> " />
134
+ <span class="text_label" title="Click to toggle toggle the enabled state">(counts as one parameter)</span>
135
+ </p>
136
+
137
+ <p>
138
+ <textarea rows="3" cols="15" name="textarea1"><?php echo $ input ['textarea1 ' ]; ?> </textarea>
139
+ <span class="text_label" title="Click to toggle toggle the enabled state">(counts as one parameter)</span>
109
140
</p>
110
141
111
142
<p>
112
143
<select name="select2">
113
144
<option value="value1">Value 1</option>
145
+ <option value="value2">Value 2</option>
114
146
</select>
147
+ <span class="select_label" title="Click to toggle toggle the enabled state">(counts as one parameter)</span>
115
148
</p>
116
149
117
150
<p>
118
151
<input type="radio" name="radio1" value="value1" checked />
119
152
<input type="radio" name="radio1" value="value2" />
120
153
<input type="radio" name="radio1" value="value3" />
121
- Radio 1
154
+ <span class="radio_label" title="Click to toggle toggle the enabled state"> Radio 1</apan>
122
155
</p>
123
156
124
157
<p>
125
158
<input type="radio" name="radio2" value="value1" checked />
126
159
<input type="radio" name="radio2" value="value2" />
127
160
<input type="radio" name="radio2" value="value3" />
128
- Radio 2
161
+ <span class="radio_label" title="Click to toggle toggle the enabled state"> Radio 2</apan>
129
162
</p>
130
163
131
164
<hr />
@@ -145,7 +178,8 @@ function getFormSubmissionLimit($default = false)
145
178
<?php foreach ($ input ['select1 ' ] as $ key => $ value ) { ?>
146
179
<option value="<?php echo "$ key " ; ?> " <?php echo ($ value ? "selected='selected' " : "" ) ?> ><?php echo $ key ; ?> </option>
147
180
<?php } ?>
148
- </select> (counts as up to three parameters)
181
+ </select>
182
+ <span class="select_label" title="Click to toggle toggle the enabled state">(counts as up to three parameters)</span>
149
183
</p>
150
184
151
185
<p>
0 commit comments