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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:47:51+00:00 2026-06-11T18:47:51+00:00

I have a javascript code with functions: function convertTime() function loadZive() Let’s say that

  • 0

I have a javascript code with functions:

function convertTime()
function loadZive()

Let’s say that I have the following code:

function convertTime(){
    alert(exampleVariable);
    };
function loadZive(){
    var exampleVariable = 3;
    convertTime();
    };

It looks like my convertTime() function can’t access exampleVariable. Is there any workaround?

Here is whole code:

function convertTime(publishedDate){
    alert(publishedDate);
    var date = publishedDate;
    var publishedDay = date.toLocaleDateString();
    var publishedHour = date.getHours();            //nemozno pouzit toLocaleTimeString (cielovy format ma byt bez sekund)
    if (publishedHour < 10){
        publishedHour = "0" + publishedHour;
    };
    var publishedMinute = date.getMinutes();        //nacitanie hodin a minut
    if (publishedMinute < 10){
        publishedMinute = "0" + publishedMinute;
    };
    var publishedTime = publishedHour +":"+ publishedMinute;    //ich nasledne spojenie do casoveho formatu HH:MM
    var publishedDateConverted = publishedDay +", "+ publishedTime;
};
function loadZive(publishedDateConverted){
google.load("feeds", "1");  
    function initialize() {
        var feed = new google.feeds.Feed("http://www.zive.sk/rss/sc-47/default.aspx");
        feed.setNumEntries(window.localStorage.getItem("entriesNumber"));
        feed.load(function(result) {
            if (!result.error) {
                var feedlist = document.getElementById("feedZive");
                for (var i = 0; i < result.feed.entries.length; i++) {
                    var li = document.createElement("li");
                    var entry = result.feed.entries[i];
                    var A = document.createElement("A");
                    var descriptionSettings = window.localStorage.getItem("descriptionSettings");
                    if (descriptionSettings=="true"){
                        var h3 = document.createElement("h3");
                        var p = document.createElement("p");
                        var pDate = document.createElement("p");
                        pDate.setAttribute("class","ui-li-aside");
                        var publishedDate = new Date(entry.publishedDate);
                        convertTime();
                        pDate.appendChild(document.createTextNode(publishedDateConverted));
                        h3.appendChild(document.createTextNode(entry.title));
                        p.appendChild(document.createTextNode(entry.content));
                        A.setAttribute("href",entry.link);
                        A.appendChild(h3);
                        A.appendChild(p);
                        A.appendChild(pDate);
                        }
                    else{
                        A.setAttribute("href",entry.link);
                        A.appendChild(document.createTextNode(entry.title));
                    };
                    li.appendChild(A);
                    feedlist.appendChild(li);
                }
                $("#feedZive").listview("refresh");
            }
        });
    }
    google.setOnLoadCallback(initialize);   
};

Alert result is Undefined.
PS: exampleVariable isn’t defined by the user; it is loaded from a feed, so I cannot define it before the convertTime() function.

  • 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-11T18:47:52+00:00Added an answer on June 11, 2026 at 6:47 pm

    As Danny said, or you can also pass variables this way:

    function convertTime(exampleVariable){
        alert(exampleVariable);
    };
    function loadZive(){
        var exampleVariable = 3;
        convertTime(exampleVariable);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
I have the following Javascript code that works perfectly: $(document).ready(function() { $(#Select1).setDefault(); $(#Select2).setDefault(); $(#Select3).setDefault();
Okay, I have a JavaScript file with the following functions: function AskReason() { var
I have a JavaScript function code where I want to alert. function msgalert(x,y) {
I have a JavaScript function code where I want to alert. function msg(x,y) {
I have seen Javascript code that uses parenthesis immediately after a function's closing curly
I have this javascript code <Script> function getGroupId(){ var group=document.getElementById(selectedOptions).value; var groupFirstLetter=group.substring(2); } </Script>
I have the following Javascript code (using jQuery): floatUpAndDown(); function floatUpAndDown() { $(#bird).animate({top: '+=30px'},
So I have the following JavaScript code: <script type=text/javascript> function clearRadioButtons() { document.getElementById(radiobutton1).checked=; //etc
I have the following JavaScript code which is inside a function which I am

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.