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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:04:24+00:00 2026-06-08T10:04:24+00:00

To be honest Im not sure how to frame this question, but here goes.

  • 0

To be honest Im not sure how to frame this question, but here goes.

I have a form with the following input fields:

<input name="key[23]" type="text" />
<input name="key[29]" type="text" />
<input name="key[65]" type="text" />

I can create an array with Jquery to send to the PHP script like so:

    var new_keys = new Array();
$('input[name="keys[]"]').each(function() {
    new_keys.push($(this).attr('value'));
});

However I dont know how to create the array when the input fields already have a key: input name=”test[45]”

I tried changing my method to using a class selector instead of the input name, but I cant get the keyname.

What I need to do is send the keyname and its value to PHP so I can update a table where the keyname equals the table ID number. This is simple to do if I wasnt using Ajax.

Hope that makes sense.

Edited

<form method="post" id="add-form" class="form" onsubmit="return false;">
<input class="required" type="text" name="name" id="name" />
<input class="required" type="text" name="keys[32]" />
<input class="required" type="text" name="keys[65]" />
<textarea name="Test"></textarea>
<input type="submit" name="submit" value="submit" />
</form>

$(document).ready(function() {
    $.fn.submitForm = function() {
        var name = $('#name').attr('value');
        var new_keys = new Array();
        $('input[name="keys[]"]').each(function() {
            new_keys.push($(this).attr('value'));
        });

        $.ajax({
            type: 'POST',
            data: { 'new_keywords' : new_keywords, 'name' : name },
            dataType: 'json',
            url: 'article/scripts/article.scripts.php',
            success: function($data) {
                var result = $data.result;
                var msg = $data.msg;

                if (result == "success") {
                    formMessageDisplay(msg, result);
                }
                else {
                    formMessageDisplay(msg, result);
                }
            },
            error: function($data) {
                formMessageDisplay('<?php echo AJAX_ERROR; ?>', result);
            }
        })
    }
});

This is a cutdown version of the script that I have.

  • 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-08T10:04:26+00:00Added an answer on June 8, 2026 at 10:04 am

    You could do something like this which should grab the names of the fields and then assign the values in the array. You can then process and clean it up in PHP as needed:

    var new_keys = new Array();
    $('input[name="keys[]"]').each(function() {
        new_keys[$(this).attr('name')] = $(this).attr('value');
    });
    $.post('url/to/script/here.php', new_keys, function(data) {
        // process data here on success
    }, 'json'); // expecting a json object
    

    For further reading on ajax look @ this for using the post method http://api.jquery.com/jQuery.post/

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

Sidebar

Related Questions

I am not sure this is even possible to be honest, I am wondering
To be honest, I'm not sure if this is an issue with my code
I am sure this question has been asked but I can't find anything that
this may sound like a strange question from a Python noob, but here's the
To be honest I'm not quite sure if I understand the task myself :)
I'll be honest, I am not sure of the terms I used in the
To be honest, I do not really know how to name that problem. I'll
I'm going to be honest: this is a question I asked on the Django-Users
I'm not sure where to start with this, I've been building an app over
Now I have googling this a lot, but I cant seem to find what

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.