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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:56:05+00:00 2026-06-07T08:56:05+00:00

I am looking for a really simple way of getting all the values from

  • 0

I am looking for a really simple way of getting all the values from all input elements (and some dividers as well) and then quickly sending them to a PHP file with an already prepared submit function.

I have came up with a very crude solution but it needs to be heavily optimized.

For now when I click submit button I call a function

function $('#submit').click(function(){

var $divValues = new Array();
$divValues[0] = $('#divName').html();
$divtValues[1] = $('#divImgName').html();

var $values;
$values = $(':input').serializeArray();

$fileName = "php.php?firstVal=\""+$divValues[0]+"\"&secondVal=\""+$divtValues[1]+"\"&thirdVal=\""+$values['firstValName']+"\"&ect..." 

//then i simply call the ajax function which will send the information to the php file
fetch($fileName);    
});

maybe i could use the fact that the names of values in my associative array and the names of variables retrieved in my php file match and instead of setting my filename to ..."&thirdVal=\"" ... I would instead use the name of the $values['firstValName'] which in this example would be third value (although i have no idea how to do that)

or maybe there is an even easier way to accomplish what im trying to.
Any ideas on how to implement this piece of code in a nice manner??

Update:

For now I don’t have a form element in my html but I can easily add one as soon as I see a solution that requires it to make the code simpler…
I know I can use serialize() function but my questions is about a nice way of dealing with the array that gets returned. (or maybe using 2 arrays one with name other with value or a 2 dimensional array)
Either way I just wish to see what is an easy way of both getting the data and creating the $fileName with correct values for the PHP file

I would appreciate some code or pseudocode in the answer that shows a simple way of creating the fileName with all the values

If anybody doesn’t understand what I am asking or needs some clarification then they should feel free post a comment below so I can try to make myself clear.

  • 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-07T08:56:06+00:00Added an answer on June 7, 2026 at 8:56 am

    Since you’re using jQuery, you could use its AJAX methods with serialize() applied to the entire form. You can read documentation about it by clicking here. Also you can read documentation about jQuery’s AJAX methods by clicking here, here and here.

    In response to your request, here is a really simple example:

    $.post("test.php", $("#testform").serialize());
    

    You could really get the rest of what you need on how to use $.post or $.get functions from the documentation I referenced.

    Serialize also takes care of urlencoding all the variables so you don’t have to worry about that.

    EDIT:

    It’s not really necessary to have a form. You could just do what you are trying to do with serializeArray() above, except (a) $(‘:input’) does not select anything and (b) you should use serialize() and not serializeArray(). So without a form, the code would look as follows:

    $.post("test.php", $("input,select,textarea").serialize());
    

    This will properly request the script with the data encoded correctly and you can then read it in PHP script from $_POST or $_GET depending on whether you used $.post or $.get to request the script.

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

Sidebar

Related Questions

I'm looking for a really simple of way stripping content from this string: Example:
This might have been asked before but I'm really looking for a simple way
I'm looking for good tutorial or really simple code to integrate mongokit and django
I'm really looking for something very similar to the way SO is setup where
I am looking for a very simple way to post status updates to a
I'm using ASP.NET webforms and lots of javascript/jQuery. I'm looking for a really simple
I've been looking for a way to update my Twitter status from a Python
I'm looking for a simple way to persist objects when experimenting and creating mock
This is probably stupid simple, but for some reason I'm having trouble getting it
I'm looking for a simple way to create a user multi-parameter receiving function, Here's

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.