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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:56:47+00:00 2026-06-08T05:56:47+00:00

I’m making a dynamic select menu using Jquery mobile. First problem that i am

  • 0

I’m making a dynamic select menu using Jquery mobile.
First problem that i am facing is that Placeholders are not appearing
for both ie statically created option “–select day–” and “–select time–” which i have statically created in html file. It is just loading the dynamically created values.
Second problem and the Important one is that I want to load “PMtime” if user selects the “Today-Drop”, and “AMtime” if user selects the “Tomorrow-Pick up” option. I created an event handler for it but it seems not working. Please help….
HTML code:

<body onload="init();">
<form method="get" name="datarange">
<div data-role="fieldcontain">

    <select id="select-choice-1" name="select-choice-1"  class="target" >
        <option data-placeholder="true">--Select Day--</option>

  </select>
    </div>
<div data-role="fieldcontain">
<select id="select-choice-2" name="select-choice-2" >
    <option data-placeholder="true">--Select Time--</option>

</select>
    <script>
        $('.target').change(function(){
                            var str="";
                            $("select option:selected".each(function(){
                                                            str+=$(this).text() + "";
                                                            });
                              if(str.text=="Today-Drop")
                              {
                              check=0;
                              }
                              else
                              {
                              check=1;
                              }
                            Load_selected_time(check);

                            })
                            .trigger('change');

   </script>
    </div>

And in my JS file

var check=0;
var day=[
     {name : "Today-Drop",id: "drop"},
     {name : "Tomorrow-Pick up",id: "pickup"}];
var PMtime=[
        {name : "3:00 PM", id: "3"},
        {name : "4:00 PM", id: "4"},
        {name : "7:30 PM", id: "730"},
        {name : "9:00 PM", id: "9"},
        {name : "10:15 PM",id: "1015"},
        {name : "11:00 PM",id: "11"}];
var AMtime=[
        {name : "12:00 AM", id: "12"},
        {name : "1:00 AM" ,id: "1"},
        {name : "2:00 AM" ,id: "2"},
        {name : "3:00 AM" ,id: "3am"},
        {name : "4:00 AM" ,id: "4"},
        {name : "5:00 AM" ,id: "5"},
        {name : "6:00 AM" ,id: "6"},
        {name : "7:00 AM" ,id: "7"},
        {name : "8:00 AM" ,id: "4"},
        {name : "9:00 AM" ,id: "5"}];

function init(){
                 Load_selected();}
function Load_selected() {

var arraytoload = day;
var  optionlist = '';
var i = 0;

$.each(arraytoload, function (index,item) {
       if (i == 0) {
       optionlist += '<option selected="' + item.id + '">' + item.name + '</option>';
       }
       else {
       optionlist += '<option value="' + item.id + '">' + item.name + '</option>';
       }
       i++;
       })
optionlist += '';
$("#select-choice-1").html(optionlist).selectmenu('refresh', true);
}

function Load_selected_time(check){
if(check==0){
    var arraytoload = PMtime;}
else{
    var arraytoload = AMtime;
}
var  optionlist = '';
var i = 0;

$.each(arraytoload, function (index,item) {
       if (i == 0) {
       optionlist += '<option selected="' + item.id + '">' + item.name + '</option>';
       }
       else {
       optionlist += '<option value="' + item.id + '">' + item.name + '</option>';
       }
       i++;
       })
optionlist += '';
$("#select-choice-2").html(optionlist).selectmenu('refresh', true);
}
  • 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-08T05:56:48+00:00Added an answer on June 8, 2026 at 5:56 am

    Your first problem (placeholders not being shown) occurs, because you’re overwriting the content of both .

    Try to initialize your ‘optionslist’ string in both functions with

    var optionslist = $('yourselect').html();
    

    before adding the items to that string in the ‘each’ loop.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.