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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:04:25+00:00 2026-05-29T08:04:25+00:00

I am working offline with SQLite, Javascript and Chrome In my main page (main.html),

  • 0

I am working offline with SQLite, Javascript and Chrome
In my main page (main.html), I have two div: <div id="menuLeft"> that contains the list of items name with buttons to edit each item, and

<div id="content">

The list of item is written as follows:

<li>ItemName1
    <div id="idItem1" class="editItem_btn">
        <img src="btn_edit.png">`
    </div>
</li>

In main.html, I have the following code:

$("#menuLeft").delegate(".editItem_btn", "click", function(e0)
     {
        e0.preventDefault();
        var editItemId = $(this).attr("id");
        editItemId = parseInt(editItemId);
        var url="edititem.html"
        $("#content").load(url,function(){
        loadRecord(editItemId);`
    });
});

When I click on the edit button of a given Item, the id of the Item is first retrieved from the id of the div around the edit button. Then I load the page edititem.html content. On success, I run the function loadRecord(editItemId), where loadRecord(i) is contained in edititem.html:

function loadRecord(j) 
{
    var item = dataset.item(j);
    idItem.value = item['id'];
    ItemName.value = item['ItemName'];
    dateStart.value = item['dateStart'];
    dateEnd.value = item['dateEnd'];
    notes.value = item['notes'];
}

This function enables to display the parameters of Item (id, ItemName….) contained in the database.

Here is my problem, the code works but in a weird way meaning that if I click on the edit button of Item1, the parameters of Item2 are displayed. Same thing if I click on edit Item2, parameters of Item3 are displayed.

I then replaced:

var item = dataset.item(j);

with:

var item = dataset.item(j-1);

and that works. But I need to understand why it’s behaving like that, and why I need to use (j-1). I placed some alert() in the jquery code to check that I have the right editItemId number, and in the function loadRecord(j). The right id number is retrieved after the click and the right id number is passed to the function. I have no idea what’s the bug here!

  • 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-29T08:04:26+00:00Added an answer on May 29, 2026 at 8:04 am

    Without seeing the sql side of things, and how that data is passed back to your script it’s impossible to tell you exactly what’s happening, but this is simply a case of some lists being 0 based and some lists being 1 based. For example, arrays are generally 0 based (unless you specifically create them a different way), but $(“#id”).each(function(Index)… is 1 based. You just have to know what you’re working with and occasionally do as you have found and use -1 or +1 when relevant.

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

Sidebar

Related Questions

I have to design an webapp that has the capability of working offline. So
We have an offline set of HTML pages we're working with using HTML5 document
Working with a SqlCommand in C# I've created a query that contains a IN
I'm working on an iPhone application that should work in offline and online modes.
I'm working with a app that has both online datastore(GAE) and an offline datastore(HTML5
I have been working offline for a couple of days so I didn't have
I have an MVC2 web site which I am trying to get working offline
I have a simple Delphi (2007) procedure that given a TDataSet and a (sub)list
This is a weird one. I'm working on an app that allows for offline
I am working on a webapplication that uses caching to make it available offline.

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.