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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:39:20+00:00 2026-06-10T19:39:20+00:00

I run into a little problem that needs your help. I am coding in

  • 0

I run into a little problem that needs your help. I am coding in a Joomla module, but this is not really a problem to all those who are not Joomla-friendly.

In a Joomla’s module, there will be a folder named tmpl (template for short I think) that contains a little file default.php, which is where the view will be presented to the browser. Here is roughly a part of the file I am dealing with

!DOCTYPE HTML
<?php 
// perform some initialization
?>

<script language="javascript">
$(document).ready(function()
{
    var obj=["o1","o2","o3","o4",...,"o_n"];
    //do something with range obj
});

</script>

<div>
    <div class="content">
        <?php
            if(is_set($array))
            {
                foreach($array as $key=>$val):
            ?>
                //GET $val->id
            <?php
                //display $val->$content
            }
        ?>
    </div>
</div>

In the foreach loop I would like to get all the integral ids inside $val which will be fed back into the above javascript’s obj variable as strings. I would need this to be done automatically; when the page loaded, the obj in javascript is initialized and when I added a new $val item into the database, this must too be done automatically (I don’t have to open this default page to edit the obj).

Do you understand the problem I am having right now, please ask and reply. Thank you

  • 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-10T19:39:22+00:00Added an answer on June 10, 2026 at 7:39 pm

    One solution would be to build the array you want to pass to JS in PHP, then json_encode it and pass it as is to JS. It would be easier than to build it in JS, then afterwards extend it via generated JS code. See this for example:

    !DOCTYPE HTML
    <?php 
    // perform some initialization
    ?>
    
    <?php
    $obj = array("o1","o2","o3","o4",...,"o_n");
    if(is_set($array)) {
        foreach($array as $key=>$val) {
            $obj[] = $val->id;
        }
    }
    ?>
    
    <script language="javascript">
    $(document).ready(function()
    {
        var obj=<?php echo json_encode($obj); ?>;
        //do something with range obj
    });
    
    </script>
    

    Another way would be to use AJAX calls to fill this array, but that’s not always the best approach, so I’ll leave it up to you to decide.

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

Sidebar

Related Questions

I have run into a little problem. I am connecting to a webservice that
This is not a problem that needs answering, more of a query on why
I've run into a little theoretical problem. In a piece of code I'm maintaining
I've run into a little difficulty and I'm not sure how best to solve
I've run into a little hurdle and wanted to see if somebody could help
I run into this problem. I have a textarea which I only want to
I have a curious little problem. I have a service that needs to create
I'm currently developing a web application and have run into a little problem. I'm
I've done a bit of googling round but this particular problem is a little
I'm using (fluent) nhibernate and I've run into a little problem. My data model

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.