| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<!-- |
| 5 |
|
| 6 |
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
| 7 |
|
| 8 |
Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. |
| 9 |
|
| 10 |
The contents of this file are subject to the terms of either the GNU |
| 11 |
General Public License Version 2 only ("GPL") or the Common Development |
| 12 |
and Distribution License("CDDL") (collectively, the "License"). You |
| 13 |
may not use this file except in compliance with the License. You can |
| 14 |
obtain a copy of the License at |
| 15 |
http://glassfish.java.net/public/CDDL+GPL_1_1.html |
| 16 |
or packager/legal/LICENSE.txt. See the License for the specific |
| 17 |
language governing permissions and limitations under the License. |
| 18 |
|
| 19 |
When distributing the software, include this License Header Notice in each |
| 20 |
file and include the License file at packager/legal/LICENSE.txt. |
| 21 |
|
| 22 |
GPL Classpath Exception: |
| 23 |
Oracle designates this particular file as subject to the "Classpath" |
| 24 |
exception as provided by Oracle in the GPL Version 2 section of the License |
| 25 |
file that accompanied this code. |
| 26 |
|
| 27 |
Modifications: |
| 28 |
If applicable, add the following below the License Header, with the fields |
| 29 |
enclosed by brackets [] replaced by your own identifying information: |
| 30 |
"Portions Copyright [year] [name of copyright owner]" |
| 31 |
|
| 32 |
Contributor(s): |
| 33 |
If you wish your version of this file to be governed by only the CDDL or |
| 34 |
only the GPL Version 2, indicate your decision by adding "[Contributor] |
| 35 |
elects to include this software in this distribution under the [CDDL or GPL |
| 36 |
Version 2] license." If you don't indicate a single choice of license, a |
| 37 |
recipient has the option to distribute your version of this file under |
| 38 |
either the CDDL, the GPL Version 2 or to extend the choice of license to |
| 39 |
its licensees as provided above. However, if you add GPL Version 2 code |
| 40 |
and therefore, elected the GPL Version 2 license, then the option applies |
| 41 |
only if the new code is made subject to such option by the copyright |
| 42 |
holder. |
| 43 |
|
| 44 |
--> |
| 45 |
|
| 46 |
<title>A Form</title> |
| 47 |
<script type="text/javascript"> |
| 48 |
function setColours() { |
| 49 |
var http_request = new XMLHttpRequest(); |
| 50 |
if (document.bio.hint.value.length > 0) |
| 51 |
http_request.open("GET", "form/colours?match="+document.bio.hint.value, false); |
| 52 |
else |
| 53 |
http_request.open("GET", "form/colours", false); |
| 54 |
http_request.setRequestHeader("Accept", "application/json"); |
| 55 |
http_request.send(null); |
| 56 |
if (http_request.status == 200) { |
| 57 |
list = eval("(" + http_request.responseText + ")"); |
| 58 |
document.bio.colour.options.length = 0; |
| 59 |
document.bio.colour.options[0] = new Option("Pick a colour", "", true, false); |
| 60 |
for (var i = 0; i<list.length; i++) { |
| 61 |
document.bio.colour.options[i+1] = new Option(list[i], list[i], false, false); |
| 62 |
} |
| 63 |
} else { |
| 64 |
alert("There was a problem fetching the list of colours."); |
| 65 |
} |
| 66 |
http_request = null; |
| 67 |
} |
| 68 |
</script> |
| 69 |
</head> |
| 70 |
<body> |
| 71 |
<p>Tell me about yourself:</p> |
| 72 |
<form name="bio" action="form" method="POST"> |
| 73 |
<table> |
| 74 |
<tr> |
| 75 |
<td align="right">Name:</td> |
| 76 |
<td><input type="text" name="name" value="" size="30" /></td> |
| 77 |
</tr> |
| 78 |
<tr> |
| 79 |
<td align="right">Favorite colour:</td> |
| 80 |
<td> |
| 81 |
<select name="colour" onmousedown="setColours()"> |
| 82 |
<option>Pick a colour</option> |
| 83 |
</select> <i>Populated dynamically when you click on the control</i><br/> |
| 84 |
<input type="text" name="hint" value="" size="13"/> <i>Type a hint to reduce the number of options</i> |
| 85 |
</td> |
| 86 |
</tr> |
| 87 |
<tr> |
| 88 |
<td></td> |
| 89 |
<td> |
| 90 |
<input type="submit" value="Submit" name="submit" /> |
| 91 |
</td> |
| 92 |
</tr> |
| 93 |
</table> |
| 94 |
</form> |
| 95 |
</body> |
| 96 |
</html> |