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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:19:18+00:00 2026-06-05T04:19:18+00:00

I am having a JSON object var jsonString =[ { key: Monday, June 18,

  • 0

I am having a JSON object

var jsonString =[
    {
        "key": "Monday, June 18, 2012",
        "value": "10 00 AM|_mod,11 00 AM|_mod,12 00 PM|_mod,13 00 PM|_mod"
    },
    {
        "key": "Tuesday, June 19, 2012",
        "value": "13 00 PM|_mod,13 30 PM|_mod,14 00 PM|_mod,14 30 PM|_mod,15 00 PM|_mod"
    }
];

I have two drop-downs I am trying to match the key selected from the first drop-down with the key in the JSON and populate the second drop-down with the appropriate values.
I want the option tag to look like this

<option value="10 00 AM|_mod">10 00 AM</option>

but I am seeing this

enter image description here

I think the empty spaces in the 10 00 AM|_mod are causing a problem when the DOM is getting created.

This is my JS code.

$('#event_date').change(function() {
    var event_date = $("#event_date").val(); // first drop-down val
    var time_type = null;
    var time = null;
    for (var x = 0; x < jsonString.length; x++) {
        if (event_date == jsonString[x].key) {
            var value = jsonString[x].value;
            console.log(value);  // output: 10 00 AM|_mod,11 00 AM|_mod,12 00 PM|_mod,13 00 PM|_mod
            var value_split = value.split(",");
            for (var i = 0; i < value_split.length; i++) {
                console.log(value_split[i]);    // works fine at index 0 I get 10 00 AM|_mod
                time_type = value_split[i].split("|");
                time = time_type[0];
                $('#timeslotIdentifier').append("<option value =" + value_split[i] + ">" + time + "</option>");
            };
        };
    };
});

Is there an encoding problem ? I tried adding breakpoints and it looks fine but when I inspect the element I am seeing this.

enter image description here

  • 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-05T04:19:20+00:00Added an answer on June 5, 2026 at 4:19 am

    You’re creating an unquoted attribute value.

    You should use jQuery instead:

    $('<option />').text(time).val(value_split[i]).appendTo('#timeslotIdentifier');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble getting some data from a JSON object which I have
I'm having JSON object var x=[{@Name:'test 1',@Sort:'1',@Status:'yes'}, {@Name:'test 2',@Sort:'5',@Status:'yes'}, {@Name:'test 3',@Sort:'4',@Status:'no'}, {@Name:'test 5',@Sort:'2',@Status:'no'}] I'm
I have created an empty json object having an array itemlist(which further contains itemid
I'm having trouble making a POST request with a JSON object using Dispatch and
Hi I am having a problems displaying my array via JSON object. I passed
I'm having an issue with passing the generated JSON notation of my object to
I created an object from PHP with json encode, but I am having difficulty
I'm having a problem. I have the list of JSON objects in a separate
Am having a JSON structure as below var myJSON = { userTypes: { @type:
I'm having a duplicate JSON file problem. I have google places SBJSON files and

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.