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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:56:44+00:00 2026-06-09T03:56:44+00:00

I am trying to grab a single variable from an array through my function

  • 0

I am trying to grab a single variable from an array through my function open_boosters(), then send the variable to my PHP script. What is the correct way to do this?

All I have at the moment is this JavaScript function that generates random numbers, called open_boosters().

><img src="site3.php?"action="document.getElementById("?").innerHTML=open_boosters();"/>

In my PHP, should I simply bind the variable with a $_GET method?

  • 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-09T03:56:46+00:00Added an answer on June 9, 2026 at 3:56 am

    It is best practice to move behaviors out of the HTML and into a <script> tag, or better, an external script file (though with the ability to attach events to HTML elements). In this case, there is no reason to bind to an image element your code which has nothing to do with the image (it looks like it is trying to populate some other element).

    <script>
    // This code will not work with older IE versions; you may
    // wish to use a library like jQuery to handle all the complexities
    // of browser compatibility; or you can avoid all this by putting
    // the script tag after your elements
    window.addEventListener('DOMContentLoaded', function () {
        var rand = open_boosters();
        document.getElementById("?").innerHTML=rand;
        document.getElementById("randImg").src = "site3.php?randomNumber"+rand;
    }, false);
    </script>
    <img id="randImg" />
    

    Then in your PHP code:

    <?php
    $_GET['randomNumber']; // Do something with it (though safely--e.g., do not add directly to a SQL string, etc.)
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to grab just a single value from some json and am
I'm trying to grab a single item from each of the Lists here, and
im trying to grab search items from twitter via PHP curl, process and update
Im trying to grab the destination (dynamic) of a link (static) with php Im
I have been trying to grab a file from an alternate git branch and
I am trying to grab the closest link with the class a.tariff-link and send
Hi I am trying to grab a div from another website using JS. I
I'm trying to grab a screenshot from a NSView, draw a string on top
I am trying to acquire single images from a camera, do some processing to
I'm trying to make a query that grabs a single row from an SQL

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.