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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:55:46+00:00 2026-05-26T15:55:46+00:00

how can i get array value from php to javascript, and use the value

  • 0

how can i get array value from php to javascript, and use the value for other function in javascript?
here is my source code:

<?php
    $sSql  = "SELECT * from contactinfo order by description, nama_cp";
    $r1 = $dbconn->execute ($sSql);
    $idset=array();
    $no=1;
    while (($r1) && (!$r1->EOF)) {
        $s1 = $r1->GetRowAssoc(false);
        $idset[$no]=$s1[id];
        $no++;
    }
?>
<script type="text/javascript">
function getdata(valarray){
    //source..
}
 $(document).ready(function() {
     var line=<?php echo($no); ?>;
     var i;
     for(i=1;i<line;i++){
        $("#action"+i).click(function() {//button, that named with action+int
            //var valarray = ??? -------->value of array idset;
            getdata(valarray);//use data array for other function..
        });
     }
 });   
 </script> 

in this code, i want to use valarray in function getdata().

  • 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-26T15:55:46+00:00Added an answer on May 26, 2026 at 3:55 pm

    Here is your solution:

    var valarray = <?php echo json_encode($idset); ?>; 
    console.log('we got: '+ valarray)
    

    When you used alert – you can see the results since it’s a json and not test. The best for you will be to use Chrome dev tools (or Firebug on FF) and see in the console the results.

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

Sidebar

Related Questions

How can I get an array of values from an associative array ? Associate
how can i get elements uniquely from an array
how can i get [user_id] from this array? Array ( [2] => cbpaidSubscription Object
I need to transfer the values from a PHP array into a JavaScript array
Can anyone describe the following php function: function get_setting_value($settings_array, $setting_name, $default_value = ) {
Please tell me how can I get array of all Those DIV of specific
How can I get the last key of an array?
I wanted to know how can we get the index of the array if
If I have an array as $keys => $values , how can I get
Can get all triples with value null in specific field? All people with date_of_birth

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.