Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9020809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:06:38+00:00 2026-06-16T05:06:38+00:00

I am using the following jquery in order to disable text boxes on my

  • 0

I am using the following jquery in order to disable text boxes on my page. The issue I am running into is that by default because its stored in the database it loads the page with “remote_server” set to 0. Even with this being set automatically the fields are still able to be modified. I must click on the selection drop down and reselect “no” for it to work.

Here is my JS

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

if ( strUser == 0 ) {

$('select[name=remote_server]').change(function(){
var inputs = $('input[name^=ftp_],select[name^=ftp_]');
$(this).val() == "0" ? inputs.attr("disabled", "disabled") : inputs.removeAttr("disabled");
});
}

My remote_server HTML code for the drop down selection.

<select name="remote_server" class="required">
<option></option>
<option value="1" <?php if($remote=="1") echo 'selected="selected"'; ?>>Yes</option>
<option value="0" <?php if($remote=="0") echo 'selected="selected"'; ?>>No</option>
</select>

Loading the page I an see where the option 0 is selected aswell which is why this puzzles me

<select name="remote_server" class="required">
<option></option>
<option value="1" >Yes</option>
<option value="0" selected="selected">No</option>
</select>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:06:39+00:00Added an answer on June 16, 2026 at 5:06 am

    You should trigger the change event:

    $('select[name=remote_server]').change(function(){
       var inputs = $('input[name^=ftp_],select[name^=ftp_]');
       $(this).val() == "0" 
       ? inputs.attr("disabled", "disabled") 
       : inputs.removeAttr("disabled");
    }).change() // trigger the event
    

    Note that as of jQuery 1.6 for setting/getting properties of the elements, prop method should be used instead of attr:

    var $inputs = $('input[name^=ftp_],select[name^=ftp_]');
    
    $('select[name=remote_server]').change(function(){
         $inputs.prop('disabled', this.value === 0)
    }).change();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following jQuery plugins (along with the jQuery plugin): <script type=text/javascript src=scripts/jquery.scrollTo-min.js></script>
I'm using the following JQUERY Autocomplete plug-in: jQuery Plugin: Tokenizing Autocomplete Text Entry What'd
I have a jQuery script running that makes a periodic AJAX call using the
I have a form that I intend to submit using jQuery. The following code
In order to load a jQuery mobile page using an anchor tag, one just
I'm using the contents() function in jQuery in order to obtain some text within
I'm using the following code in my page, in order to reinitialise jScrollPane, for
I am using following plugin http://pinesframework.org/pnotify/ I am creating dialog using following jquery code..
Using the following JQuery/AJAX function I'm calling a partial view when an option is
I'm currently using the following jQuery plugin: jQuery OEmbed. This plugin works great in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.