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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:52:50+00:00 2026-06-14T02:52:50+00:00

I have the following option box: <label for=inputselection1>Input #1:</label> <select id=inputselection1 name=unittype> <option value=1>Miner</option>

  • 0

I have the following option box:

<label for="inputselection1">Input #1:</label>
<select id="inputselection1" name="unittype">
<option value="1">Miner</option>
<option value="2">Puffer</option>
<option value="3">Snipey</option>
<option value="4">Max</option>
<option value="5">Firebot</option>
</select><br>

however, when I execute the following jquery option onload, the text (selected option) does not get changed to Max:

$("#inputselection1 option[text=Max]").attr("selected","selected");

What gives?

Thanks!

  • 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-14T02:52:51+00:00Added an answer on June 14, 2026 at 2:52 am

    Use .val() to set select value by option value:

    $("#inputselection1").val(4);​
    

    If you insist on selecting by text, then use this:

    $("#inputselection1 option").filter(function() {
        return $(this).text() === 'Max';
    }).attr("selected", "selected");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code select box div: Make:<br> <select name=Make> <option value =
i have following filteringselect: <select name=v dojoType=dijit.form.FilteringSelect valueList=v id=v value=0><option value=></option><option value=0>0-test</option><option value=1>1-test2/option><option value=2>2-test3</option><option
I have the following HTML: <div data-name=countrySelectorRoot> <select> <option value=C1>Country 1</option> <option value=C2>Country 2</option>
I have the following code: <select name=to class=combo value=' <?php if(isset($_POST['reply'])) { echo <option
I have the following select box. <select id=selId> <option id='1' value='1'>1</option> <option id='2' value='2'>2</option>
I have the following HTML: <select id=testMe name=test multiple=multiple size=5 style=width:270px> <option value=test1>test1</option> <option
I have following checkbox arrays in html form <label><input name=columns[] type=checkbox value=pname />Property Name</label>
I have a select box, created in the following way: <select id=size onchange=location=this.options[this.selectedIndex].value; name=size>
I have the following dropdown list box: <select name=DDLConditional1 size=1> <option selected=selected>is equal to</option>
I have the following html element <select id=selectStates size=5 multiple=multiple class=box> <option value=tx>Texas</option> <option

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.