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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:53:15+00:00 2026-05-24T06:53:15+00:00

I have an array in Javascript that i am trying to pass to php.

  • 0

I have an array in Javascript that i am trying to pass to php. my array looks like this.

 Array[0]
   "empNo" : "1347"
   "empName" : "John Doe"  

I am building this array from this javascript:

$('input[type=text]').each(function()
{
             if ($(this).attr("value").length>0)
             {
                  param[$(this).attr("id")]=$(this).attr("value");
             }            
});

Then I pass the array to php using

$.post("example.php",param)

Then in php when I try to interact with the post like this:

$emp=$_POST['empNo'];
$name=$_POST['empName'];
echo ($_GET[0]);//this is for testing 

It throws an error saying that The Indexes of empNo and empName are not Defined.

It also says that 0 is an undefined offset.
Thanks for the help

  • 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-24T06:53:17+00:00Added an answer on May 24, 2026 at 6:53 am

    Instead of looping through and manually building your data to pass just do this for the whole form.

    var data = $('form').serialize();
    
    $.post("example.php", data);
    

    Then you should have access as you expect in your php script.

    BUT make sure you’re using the <input name="exampleName" /> attribute and then try to access them like this…

    $value = $_POST['exampleName'];
    

    while right now, it looks like you’re trying to use the id instead of name

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

Sidebar

Related Questions

Possible Duplicate: Length of Javascript Associative Array I have a JSON that looks like
I have a one-dimensional array of strings in JavaScript that I'd like to turn
I'm creating my own JavaScript Array-like object and I have methods that call closures.
I'm trying to pass a javascript Date object to a controller that I have
I have an array($my_array) that looks something like: array(2) { [25]=>int(10) [30]=>int(8) } I'd
I have a JavaScript object that looks like the following: venue = function(map, dataSet)
I have an external JavaScript that contains: function random_imglink(){ var myimages=new Array() myimages[1]="http://sevir.sitegoz.com/jchs/Banner1.png" myimages[2]="http://sevir.sitegoz.com/jchs/banner2.png"
1) I have this Javascript array: lang=new Array(); lang[sq]=Albanian; lang[ar]=Arabic; lang[en]=English; lang[ro]=Romanian; lang[ru]=Russian; 2)
I'm trying to build an array in javascript that contains a list of ids.
I'm trying to pass local variables to an inline function in javascript and have

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.