1

I am attempting to use javascript to detect if "remote_server" is set to 0, if it is then disable the text box "ftp_hostname". If I uncomment the alert it works, however the field is still not disabled.

Text box:

<label for="ftp_hostname">
FTP Hostname
</label>
<input type="text" value="<?php echo $row['ftphost']; ?>" class="required" name="ftp_hostname" class="text"> 

Javascript:

var e = document.getElementsByName("remote_server")[0]
var strUser = e.options[e.selectedIndex].value;

if ( strUser == 0 ) {
document.getElementsByName("ftp_hostname")[0].disabled
//alert("selected!");
}

2 Answers 2

5

Try using

document.getElementsByName("ftp_hostname")[0].setAttribute("disabled", "disabled");
Sign up to request clarification or add additional context in comments.

Comments

0

you have to add =true

document.getElementsByName("ftp_hostname")[0].disabled=true;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.