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

  • Home
  • SEARCH
  • 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 7907143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:17:24+00:00 2026-06-03T11:17:24+00:00

Here is my javascript: $(‘#Service’).val(2); $(#Service).change(); // Sets new options in subservice. $(‘#Subservice’).val(5); //EDIT:

  • 0

Here is my javascript:

  $('#Service').val("2");
  $("#Service").change(); // Sets new options in subservice.
  $('#Subservice').val("5");
  //EDIT:
  alert($('#Subservice').length); // Returns 1, when there are far more in it.

Service and Subservice are drop down boxes.

On Service change, the new list of subservices is populated.

This is setting the fields of the record to be editted. It executes when I click an Edit Button.
It sets the service dropdownbox, then is populating the subservice dropdown box, then attempting to set the correct dropdown selection for it.

However it is not correctly setting the subservice box. The options are correct, so .change() is working and service sets correctly. However Subservice is not being set. And there is an entry with value 5 in it.

My only reasoning is that .change is firing, but carrying on to setting .val before it finishes. And so no options exist at the time of setting. However I dont see why it would be threading either. So Im not sure what is going on or how to fix it.

  • 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-03T11:17:26+00:00Added an answer on June 3, 2026 at 11:17 am

    change last line in your code as

    setTimeout(function(){ 
        $('#Subservice').val("5");
    }, 10);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my Javascript... <script type=text/javascript> function validator() { var x = parseInt(document.MyForm.textnuming.value); alert(x);
Here is some javascript that I wrote that attempts to change the theme of
How to show something similar to an alert like SO does here with javascript?
Sorry, still reasonably new to Javascript here, so hope this question isn't too embarrassingly
Hi very new to javascript here and jquery and absolutely don't know what I'm
Very new to javascript here folks, so forgive the newbie question. I want to
New to jQuery/javascript here and looking for a little help. I am writing a
new with javascript here. I have a simple form that takes what the user
I need to use basic javascript here and I'm not well versed with it.
As an extension to this question here Linking JavaScript Libraries in User Controls I

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.