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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:56:55+00:00 2026-05-25T12:56:55+00:00

First, I want to apologize for the ambiguous title :) Second, I’m a novice

  • 0

First, I want to apologize for the ambiguous title 🙂
Second, I’m a novice with jQuery.

I have a drop down with two values (“taget1” and “target2”). On page load, I’m setting the localStorage with a URL for each target (target1=google.com and target2=gmail.com).

When the drop down changes, I set a “lastSelection” var in localStorage (lastSelection=target2).

Now, I also want to get the relevant URL from localStorage. So when I change to “target2” I want to get the saved URL from localStorage. Instead of using an “if”, I thought I can use the val() of the drop down.

This did not work:

var url = localStorage.getItem([lastSelection])

How can I use the value of lastSelection to get a result like localStorage.getItem('target2')?

  • 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-25T12:56:56+00:00Added an answer on May 25, 2026 at 12:56 pm

    It seems ‘target1’ and ‘target2’ are text that appear in the dropdown. You could use:

    var selectedText = $("#dropdownId option:selected").text();
    

    If they refer to the actual value of the options instead of text, then

    var selectedValue = $("#dropdownId option:selected").val();
    

    Now you can use selectedText or selectedValue, which ever one you want as a parameter to get stuff from local storage.

    var url = localStorage.getItem(selectedText);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First I want to describe my situation briefly. I have two classes, one MainClass
First I want to apologize for such a silly question but I'm quite new
I want to apologize for my bad english first. I am trying to implement
I have an object which I first want to rotate (about its own center)
I have a problem but first i want to know if im working on
First off, I want to apologize beforehand, as I know there is a lot
First I'll apologize for the unclear title of my question. I wasn't sure how
at first I want to make my apologize for my english I've a problem
I couldn't think of a decent title, so let me first apologize for that.
First of all, I want to apologize for such a long question. You don't

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.