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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:15:13+00:00 2026-06-01T07:15:13+00:00

I am trying to create a small web app that will allow users to

  • 0

I am trying to create a small web app that will allow users to create a list of movies they want to see. So far, I’ve been able to get the list to be sortable and I’ve implemented the ability to add divs to the list. I’ve also been able to use localStorage to save the first div, but not the rest. The rest are clones of the first.

My JS:

$(document).ready(function(){
    $("#movie-list").sortable({
        handle : '.handle',
        update : function(){
        var order = $("movie-list").sortable('serialize');
        }
    });
    $("#add").click(function(){
        $(".movie").last().clone(true).insertAfter($(".movie").last());
    });
    $("#save").click(function(){
        var titles = $(".title").html();
        var divs = $(".movie").html();
        localStorage.setItem("UserTitles", titles);
        localStorage.setItem("divs", divs);
        alert("Your list has been saved!");
     });
     $(function(){
        if (localStorage.getItem("UserTitles")){
            var titles = localStorage.getItem("UserTitles")
        }
        else if (localStorage.getItem("divs")){
            var divs = localStorage.getItem("divs")
        }
        else{
            var titles = "New Movie";
            var divs = $(".movie").html();
        }
        $(".title").html(titles);
     });
});

My HTML:

<body>
<div id="header">MY MOVIE LIST</div>
    <div id="movie-list">
        <div class="movie">
            <img src="http://aux4.iconpedia.net/uploads/74429410244335194.png" width="16" height="16" class="handle" alt="Move" />
            <label class="title" contenteditable="true"></label>
        </div>
    </div>
    <div id="savelist">
        <img id="save" src="savelist.png" />
    </div>
    <div id="addmovie">
        <img id="add" src="addmovie.png" />
    </div>
</body>

Ideally, I want the user to press the “Save” button and have the divs that exist, their order, and their contents saved using localStorage.

  • 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-01T07:15:14+00:00Added an answer on June 1, 2026 at 7:15 am

    Calling $(".movie").html() will only give you the html for the first element found of the class movie. Instead, you want to use the each method to iterate over each element found. This can be done with the following:

    var allHTML = "";
    $(".movie").each(function(i) {
      allHTML = allHTML + this.innerHTML;
    });
    

    You can find additional documentation at http://api.jquery.com/each/.

    Update

    I reworked your ready function a bit to save the entire movie list and then reload it.

    $(document).ready(function(){
    
        $("#add").click(function(){
            $(".movie").last().clone(true).insertAfter($(".movie").last());
        });
        $("#save").click(function(){
            var titles = $(".title").html();
            var divs = $("#movie-list").html();
            localStorage.setItem("UserTitles", titles);
            localStorage.setItem("divs", divs);
            alert("Your list has been saved!");
         });
         $(function(){
            var titles = "New Movie";
            var divs = $("#movie-list").html();
            if (localStorage.getItem("UserTitles") != null && localStorage.getItem("divs") != null)
            {
                titles = localStorage.getItem("UserTitles")
                divs = localStorage.getItem("divs")
            }
            $(".title").html(titles);
            $("#movie-list").html(divs);
         });
    });
    

    I found two issues with your code. One, your localStorage.getItem("UserTitles") call was blocking the call to localStorage.getItem("divs") since you used an else if. Two, when you check for the localStorage.getItem values you need to check them against null. I also made a small change by storing the entire contents of the movie-list div in localStorage.

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

Sidebar

Related Questions

I'm trying to create a small web app that is used to remove items
I am trying create a small web application that allows a user to login
I'm trying to create a small Web App to categorize certain type of YouTube
I'm trying to create a small web service to convert PDF files to a
Trying to create a small monitor application that displays current internet usage as percentage
I'm trying to create a small Javascript framework that I can use in my
I have a small program that I'm trying to create to get ip addresses
Due project requirements, I need to create a webapp that, when executing, will allow
I am trying to figure out how to create a small web page onload()
I’m trying to create an small Web Proxy in C. First, I’m trying to

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.