Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to enable a readonly form text field using javascript

Status
Not open for further replies.

zubz

Programmer
Mar 29, 2005
14
GB
Hi,

I have a text field which is potected (read only). Now I want it to be NOT protected when A particular option is selected from a drop down select form field which appears before this form field.

<select name="mat_attended" size="1" onChange='enableDisableSubstituteMemberField(this.value)'>
<option value="Y" >Attended</option>
<option value="N" >Not Attended</option><option value="P" >Part</option>
<option value="S" >Substituted</option>
<option value="" selected></option>
</select>

<input type="text" name="mat_substitute_member_id" maxlength="8" value="" AUTOCOMPLETE="OFF" onKeyUp="this.value=this.value.toUpperCase(); protectKey('',this, true);" protected="true" class="input_id_protected" >


And this is my enableDisableSubstituteMemberField function on the select field so far which is not working.

<script language="javascript" type="text/javascript">
<!--
function enableDisableSubstituteMemberField(MAT_ATTENDED) {

//alert(MAT_ATTENDED);

if (MAT_ATTENDED == "S") {
alert("Substitute selected");
// then enable the Substitute Member form field
return setPropertyAttribute(MAT_SUBSTITUTE_MEMBER_ID, protected, NO);
} else {
//alert("something else");
// do nothing
}

}
//-->
</script>


Can anyone please help me? Thanks

 

Can you provide the source to your setPropertyAttribute function?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 

Also, are you sure you should be passing the second parameter as variable, or should it be a string (i.e. put quotes around it)?

I don't think that "protected" is a valid attribute for an HTML input element - is their STRUTS or something else at work here?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
I would do this:

Code:
<input type="text" name="mat_substitute_member_id" ... disabled="true" />

Code:
<select name="mat_attended" onchange='enableDisableSubstituteMemberField(this.options[this.selectedIndex].value)'>

Code:
if (MAT_ATTENDED == "S") {
    alert("Substitute selected");
    // then enable the Substitute Member form field
    document.forms['formName'].elements['mat_substitute_member_id'].disabled = false;
} else {
    //alert("something else");
    // do nothing
}

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top