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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:23:42+00:00 2026-05-27T00:23:42+00:00

I am using Jquery mobile, and I have these two select lists, I want

  • 0

I am using Jquery mobile, and I have these two select lists, I want to set the selected options for the to lists to the current day and month ..

edit I am using JqueryMobile

the code for 2 lists :

            <fieldset data-role="controlgroup">
            <legend>تاريخ اخر دورة شهرية : </legend>
            <label for="select-choice-day">أختر الشهر</label>
            <select name="select-choice-day" id="select-choice-day">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
                <option value="9">9</option>
                <option value="10">10</option>
                <option value="11">11</option>
                <option value="12">12</option>
                <option value="13">13</option>
                <option value="14">14</option>
                <option value="15">15</option>
                <option value="16">16</option>
                <option value="17">17</option>
                <option value="18">18</option>
                <option value="19">19</option>
                <option value="20">20</option>
                <option value="21">21</option>
                <option value="22">22</option>
                <option value="23">23</option>
                <option value="24">24</option>
                <option value="25">25</option>
                <option value="26">26</option>
                <option value="27">27</option>
                <option value="28">28</option>
                <option value="29">29</option>
                <option value="30">30</option>
                <option value="31">31</option>
                <!-- etc. -->
            </select>


            <label for="select-choice-month">اختر الشهر</label>
            <select name="select-choice-month" id="select-choice-month">
                <option value="1">يناير</option>
                <option value="2">فبراير</option>
                <option value="3">مارس</option>
                <option value="4">إبريل</option>
                <option value="5">مايو</option>
                <option value="6">يونيو</option>
                <option value="7">يوليو</option>
                <option value="8">أغسطس</option>
                <option value="9">سبتمبر</option>
                <option value="10">أكتوبر</option>
                <option value="11">نوفمبر</option>
                <option value="12">ديسمبر</option>
                <!-- etc. -->
            </select>
            </fieldset>

The code for selecting the current day and month .. but it doesn’t work !

var today = new Date();
        var day = today.getDate();
        var month = today.getMonth();
        alert(month);
        $('#select-choice-day option').get(day).attr('selected','selected');
        $('#select-choice-month option').get(month).attr('selected','selected');
  • 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-27T00:23:43+00:00Added an answer on May 27, 2026 at 12:23 am

    The problem with your code is that .get() on a jquery object returns the DOMElement at the index specified and not a jquery object anymore, so you cannot use .attr() on it (source).

    Here’s a working piece of code:

    $('#select-choice-day option[value=' + day + ']').prop('selected',true);
    $('#select-choice-month option[value=' + (month+1)  + ']').prop('selected',true);
    

    Please note that .prop() is only available for jquery 1.6 and above. If you are using an older version of the library, use attr() as you do.

    Here’s a jsfiddle

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

Sidebar

Related Questions

Using jQuery , how can I dynamically set the size attribute of a select
I am using jquery mobile in iPhone application, I have included the resources files
I am using jQuery Mobile and have few pages in one HTML page. When
Say I have a mobile web app written using JQuery Mobile, this app retrieves
I'm using jQuery Mobile to create a mobile (obviously) website. I have a list
I have a mobile app using JQuery Mobile. Because of issues with blackberry I
I have a mobile web application built using the following versions :- JQuery Mobile
I made an application using jQuery mobile, but now I have a huge problem.
I am currently developing a mobile site using jQuery mobile. I have one simple
I have my jquery mobile app pulling data from our mysql db using JSONP.

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.