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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:49:13+00:00 2026-05-25T18:49:13+00:00

I have some question. I have the html form with one hidden input element.

  • 0

I have some question. I have the html form with one hidden input element. And I have an array in my javascript code. I want to catch pressing submit button event (by using jquery) and push the array data in the hidden input.

The question is – what happens first: form date will flow to .php script or javascript’s array will be pushed into hidden input and afterwords .php script will be called? And why it is so?

TIA!

upd (code sample):

...
// process $_POST['domains']
...

<form action="registration?id=reg" method="post" enctype="multipart/form-data" id="reg_form">
    ...
    <input type="hidden" id="domains" name="domains[]" value=""/>
    ...
    <input type="submit" name="go" value="Register"/>
</form>

<script type="text/javascript">
    var domainlist = [];

    Array.prototype.indexOf = function (name) {
        var ind = -1;
        for (var i = 0; i < this.length; i++) {
            if (this[i].name == name) {
                ind = i;
                break;
            }
        }
        return ind;
    }

    $(document).ready(function() {
        ...
    });

    function checkDomain() {
        ...
            req = $.ajax({
                type:           'post',
                cache:          false,
                url:            'ajax.php',
                data:           ...,
                success: function(data) {
                    $('#domain_list_wrap').delegate('input:checkbox', 'click', function () {
                        var dmnName = $(this).attr('name');
                        domainlist.push({name: dmnName, cost: domainsArr[dmnName.split('.')[1]]});
                        ...
                    });
                    $('#domain_cart').delegate('input:checkbox', 'click', function () {
                        domainlist.splice(domainlist.indexOf($(this).attr('name')), 1);
                        ...
                    });
                }
            });
        ...
    }
</script>
  • 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-25T18:49:13+00:00Added an answer on May 25, 2026 at 6:49 pm

    The JavaScript submit event is fired when the form is submitted, but before the request is made to the server (as JavaScript runs on the client side this makes perfect sense). Therefore, the way you have imagined it working should be fine, and you can bind to the form submit event using jQuery as follows:

    $("#yourForm").submit(function() {
        //Submit event handler will run on form submit
    });
    

    The submit event handler can also be used to cancel form submission (for example, if some validation fails) by returning false. It wouldn’t really work if the data was sent to the server first!

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

Sidebar

Related Questions

I have some code which populates a hashtable with a question as the key
Following the directions at this question , I have some code running to extract
This is a really basic question but... I have some code like this var
I'm not sure if I asked the question correctly. I have some code I
I have some question: How to make a role based web application? Such as
So, i have some question about xml Documents in Java. Can i get all
I have a question about reflection I am trying to have some kind of
I have a question with fluent interfaces. We have some objects that are used
I have a question about some functionality I'm trying to add to my jQuery
A question to maybe some who have worked extensively with WinUSB APIs or user

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.