| <?xml version="1.0"?> |
| <!-- |
| Copyright 2005 The Apache Software Foundation |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <!DOCTYPE script PUBLIC |
| "-//Apache Software Foundation//Tapestry Script Specification 3.0//EN" |
| "http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd"> |
| |
| <script> |
| <!-- |
| |
| input symbols: |
| |
| select: The PropertySelection component |
| field: The matching TextField component |
| |
| Both are assumed to be in the same form. |
| |
| --> |
| |
| <input-symbol key="select" class="org.apache.tapestry.form.PropertySelection" required="yes"/> |
| <input-symbol key="field" class="org.apache.tapestry.form.IFormComponent" required="yes"/> |
| |
| <let key="formObject"> |
| document.${select.form.name} |
| </let> |
| |
| <let key="selectObject"> |
| ${formObject}.${select.name} |
| </let> |
| |
| <let key="fieldObject"> |
| ${formObject}.${field.name} |
| </let> |
| |
| <let key="functionName" unique="yes"> |
| onChange_${select.name} |
| </let> |
| |
| <body> |
| |
| function ${functionName}() |
| { |
| var select = ${selectObject}; |
| var field = ${fieldObject}; |
| |
| // Index 0 is the null value option, meaning enable the text field |
| |
| if (select.selectedIndex == 0) |
| { |
| field.disabled = false; |
| field.focus(); |
| field.select(); |
| } |
| else |
| { |
| // disabled only works with IE, not NN |
| field.disabled = true; |
| field.blur(); |
| field.value = ""; |
| } |
| } |
| |
| </body> |
| |
| <initialization> |
| <!-- Navigator is not documented to respond to the onChange event, but this works, |
| so my documentation must be wrong. --> |
| |
| ${selectObject}.onchange = ${functionName}; |
| |
| <!-- Disable the text field unless the select is set for index 0 (the null value). --> |
| |
| if (${selectObject}.selectedIndex != 0) |
| ${fieldObject}.disabled = true; |
| |
| </initialization> |
| |
| </script> |