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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:41:20+00:00 2026-06-15T07:41:20+00:00

This code below is for a form that needs to save some values into

  • 0

This code below is for a form that needs to save some values into local storage, I have got it to work in a browser, but when I load this thing up in xcode/cordova, it wont fire the function. I tried debugging, hence the many, many alerts, I tried in DWCS6 with live view, but no avail, I can’t seem to get it to run. Can you please find the error?

The function saveSpanning() has an if loop and when it goes out of the if-then-else loop it doesn’t continue in xcode simulator. In the browser it does continue.

update: what is does: there’s a slider, that produces a value, this value needs to be saved in local storage along with two other values (generated by JavaScript), namely: the date and the record count. So three values in all.

The script runs, using jquery mobile, the button to start this function works, I have use document.ready instead onBodyLoad, it basically works, but the function saveSpanning just does not go further in phonegap/ios/xcode simulator or device.

function saveSpanning() {
    alert("saveSpanning gestart!");
    var inputSpanning = document.getElementById("valSliderSpanning").value;
    alert("input spanning = " + inputSpanning);

    //For Time
    var mes_time = document.getElementById("tijdSpanning").value;
    var mestimearr = mes_time.split(":");
    //For Date
    var mes_date = document.getElementById("datumSpanning").value;
    var mesdatearr = mes_date.split("-");
    var d = new Date();
    var curr_date = d.getDate();
    var curr_month = d.getMonth() + 1; //Months are zero based
    var curr_year = d.getFullYear();
    var curr_hours = d.getHours();
    var curr_min = d.getMinutes();
    var curr_sec = d.getSeconds();
    //newDate = curr_year + "/" + curr_month + "/" + curr_date + " " + curr_hours + ":" + curr_min + ":" + curr_sec
    // origienel opmaak datum newDate = mesdatearr[0] + "/" + mesdatearr[1] + "/" + mesdatearr[2] + " " + mestimearr[0] + ":" + mestimearr[1] + ":00";
    newDate = mesdatearr[0] + "/" + mesdatearr[1] + "/" + mesdatearr[2];

    alert("deze datum wordt opgelsage: " + newDate);

    //var itemId = newDate.getTime(); //creates a unique id with the milliseconds since January 1, 1970
    var itemId = "spanningKey";
    var values = new Array();
    values.push(newDate); //push each value into our values array
    values.push(inputSpanning); //push each value into our values array
    //alert(inputSpanning);

    var spanningCountVal = localStorage.getItem('spanning_count');

    //alert(spanningCountVal);
    if (spanningCountVal == null) {
        spanningCountVal = 1;

        alert("spanningCountVal was null, en wordt dus nu 1: " + spanningCountVal);

    }
    else {
        spanningCount = parseInt(spanningCountVal) + 1;
        alert("zit nu in de else loop: " + spanningCount);

    }

    alert("uit de ifthenelseloop, spanningCount = " + spanningCount);

    itemId = itemId + '-rec-' + spanningCount;
    alert("itemid: " + itemId);
    alert("spanningCountVal: " + spanningCount);


    localStorage.setItem("spanning_count", spanningCount); //store the item in the database
    localStorage.setItem(itemId, values.join("|")); //store the item in the database
    alert("Successfully Saved.");
}


$(document).ready(function() {

    $("#button").click(function() {
        alert("hallo functie");
    });

    $("p").text("The DOM is now loaded and can be manipulated.");



    $('#button2').click(function() {
        alert('Button has been clicked');
    });
    $('#knopje').click(function() {
        saveSpanning();
    });
});​
  • 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-15T07:41:21+00:00Added an answer on June 15, 2026 at 7:41 am

    document.ready is called when all the DOM Elements are loaded, and accessible. In a browser this typically is a good time to start executing code that requires the DOM to be ready.

    However in Phonegap/Cordova, there are a number of steps that run after the document.ready event is fired, including connecting to the debugging console.

    Instead, you’ll need to wait for the deviceready event to know when phonegap/cordova is fully loaded and ready to be executed. Inside $(document).on('ready') you’ll need to add an event listener for deviceready which should fire your methods.

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

Sidebar

Related Questions

Okay this is what I have so far. I have a form that needs
I have a form that calls a success message with this code: // Form
I grabbed this code form JCarousel and just trying to understand these lines below.
This code below doesn't work correctly since my MFC program is in unicode circumstance.
I have this code below. I need to use a class id instead of
I have this code below. As you can see I am passing two variables
Below is a code snippet that is creating object. Form userexit_save_document_prepare. data: /bks/exitmanager type
I was wondering if anyone could help, I have a form that needs 4
I have a form that has a field that needs to be rendered as
Update is below code chunks. Original Question: I have an input field that is

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.