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 911331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:11:18+00:00 2026-05-15T17:11:18+00:00

I have two input fields, Id and Desc. I need a javascript which enters

  • 0

I have two input fields, Id and Desc. I need a javascript which enters the values in second text field based on some of the fields already set. Like for christmas day, if 12/25 is entered, it should say Christmas day.

Its working for one value. But if I put “else if” its not working for multiple values.

<script type="text/javascript">
$(document).ready(function() { 
    $('#holidayDate').datepicker(); 
    var availableTags = ["New years Day", "Martin Luther King Day", "Groundhog Day", "Valentine's Day", "Washington's Birthday", "Easter", "Earth Day", "National Arbor Day", "Mother's Day", "Memorial Day", "Flag Day", "Father's Day", "Independence Day", "Labor Day", "Columbus Day", "Halloween", "Veterans Day", "Thanksgiving Day", "Pearl Harbor Remembrance Day", "Christmas Day"]; 
    $("#tags").autocomplete({source:availableTags}); 
    $('#holidayDate').change(function() { 
        if ($(this).val().substring(0, 5) === '12/25') { 
            $('#tags').val('Christmas Day'); 
        }else if ($(this).val().substring(0, 5) === '01/01') { 
            $('#tags').val('New years Day'); 
        } else { 
            $('#tags').val(''); 
        }                
    }); 
}); 
</script>
  • 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-05-15T17:11:19+00:00Added an answer on May 15, 2026 at 5:11 pm

    First, you can combine those into one DOM ready event. Also, some of your code was outside the event, so that’s probably why it wasn’t working.

    $(function() {
        $('#date').datepicker();
        var availableTags = ["Christmas Day","etc"];
        $("#tags").autocomplete({source:availableTags});
        $('#date').change(function() {
            if ($(this).val().substring(0, 5) === '12/25') {
                $('#desc').val('Christmas');
            } else {
                $('#tags').val('');
            }
        });
    });
    

    UPDATE: Hopefully it’s just a poorly written example, but your given HTML is very invalid as well. Notice you are opening a <div> tag and then closing a <p> tag, among other issues like not closing your <head> tag before opening the body, etc. All of these issues could be preventing the javascript from functioning properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got two input fields which i would like to make editable with
I have a form with two input text fields: <input id=ModelName_test_0 name=ModelName[test][0] type=text> <input
I have an HTML5 Canvas on my page along with two text input fields.
I have two input text boxes which are decimal. The sum of the two
I currently have two input fields which toggle the value value to either true
I have two HTML input fields article and url . How to duplicate field
I have a form which contains a dropdown and two input fields. <h:selectOneMenu />
I have two logical groups of input fields I need to validate separately using
I have a simple form and inside there are two input fields text type.
I have two text input fields: Name:<input id=name type=text value= name=username> Age:<input id=age type=text

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.