L
Luis
When I run the following script it displays a form with a dropdown list
and four text boxes. If I select "No" from the dropdown list all the
text boxes are disabled. If I select "Yes" from the dropdown list
Internet Explorer 6 stops responding.
What I want it to do is:
- Disable all the text boxes if "No" is selected,
- Determine which text field has the focus and then select the text that
is inside the text field if "Yes" is selected
Why is it crashing IE?
<html>
<head>
<script language="JavaScript">
function IsFieldActive(fld) {
if ((document.frmFormName.OptionsList.value == "No")) {
DisableFields(fld);
}
else {
SelectFields(fld)
}
}
function DisableFields(fld) {
this.frmFormName.field1.blur(fld)
this.frmFormName.field2.blur(fld)
this.frmFormName.field3.blur(fld)
this.frmFormName.field4.blur(fld)
}
function SelectFields(fld) {
this.frmFormName.field1.focus(fld)
this.frmFormName.field1.select(fld)
this.frmFormName.field2.select(fld)
this.frmFormName.field2.select(fld)
this.frmFormName.field3.select(fld)
this.frmFormName.field3.select(fld)
this.frmFormName.field4.select(fld)
this.frmFormName.field4.select(fld)
}
</script>
</head>
<body>
<form name="frmFormName">
<table border="1" align="center">
<tr>
<td>Make Fields Active</td>
<td colspan="4">
<select name="OptionsList" size="1">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</td>
</tr>
<tr>
<td>Field 1:</td>
<td><input type="text" name="field1" value="1"
onFocus="IsFieldActive(this.form.field1.value)"></td>
<td>Field 2:</td>
<td><input type="text" name="field2" value="2"
onFocus="IsFieldActive(this.form.field2.value);"></td>
</tr>
<tr>
<td>Field 3:</td>
<td><input type="text" name="field3" value="3"
onFocus="IsFieldActive(this.form.field3.value);"></td>
<td>Field 4:</td>
<td><input type="text" name="field4" value="4"
onFocus="IsFieldActive(this.form.field4.value);"></td>
</tr>
</table>
</form>
</body>
</html>
and four text boxes. If I select "No" from the dropdown list all the
text boxes are disabled. If I select "Yes" from the dropdown list
Internet Explorer 6 stops responding.
What I want it to do is:
- Disable all the text boxes if "No" is selected,
- Determine which text field has the focus and then select the text that
is inside the text field if "Yes" is selected
Why is it crashing IE?
<html>
<head>
<script language="JavaScript">
function IsFieldActive(fld) {
if ((document.frmFormName.OptionsList.value == "No")) {
DisableFields(fld);
}
else {
SelectFields(fld)
}
}
function DisableFields(fld) {
this.frmFormName.field1.blur(fld)
this.frmFormName.field2.blur(fld)
this.frmFormName.field3.blur(fld)
this.frmFormName.field4.blur(fld)
}
function SelectFields(fld) {
this.frmFormName.field1.focus(fld)
this.frmFormName.field1.select(fld)
this.frmFormName.field2.select(fld)
this.frmFormName.field2.select(fld)
this.frmFormName.field3.select(fld)
this.frmFormName.field3.select(fld)
this.frmFormName.field4.select(fld)
this.frmFormName.field4.select(fld)
}
</script>
</head>
<body>
<form name="frmFormName">
<table border="1" align="center">
<tr>
<td>Make Fields Active</td>
<td colspan="4">
<select name="OptionsList" size="1">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</td>
</tr>
<tr>
<td>Field 1:</td>
<td><input type="text" name="field1" value="1"
onFocus="IsFieldActive(this.form.field1.value)"></td>
<td>Field 2:</td>
<td><input type="text" name="field2" value="2"
onFocus="IsFieldActive(this.form.field2.value);"></td>
</tr>
<tr>
<td>Field 3:</td>
<td><input type="text" name="field3" value="3"
onFocus="IsFieldActive(this.form.field3.value);"></td>
<td>Field 4:</td>
<td><input type="text" name="field4" value="4"
onFocus="IsFieldActive(this.form.field4.value);"></td>
</tr>
</table>
</form>
</body>
</html>