blob: fd7d024afb4f651dab6c2c88dabefd7f6d2c3eab [file] [log] [blame]
<?xml version="1.0"?>
<!-- $Id$ -->
<!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.AbstractTextField" 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>