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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:34:59+00:00 2026-06-06T03:34:59+00:00

The value of my submit button is being lost if submitted via javascript in

  • 0

The value of my submit button is being lost if submitted via javascript in Chrome v19. It works in IE8, IE9 and FF12. I have the following page that exhibits the problem:

<html>
<head>
<script type="text/javascript">
    function submitorder()
    {
        document.openord.TYPE.value='Submitted using javascript';
        document.openord.submit();
    }
</script>
</head>

<body>
<pre>
The contents of $_REQUEST are:
<?php var_dump($_REQUEST); ?>
</pre>

<form method="post" action="showParms.php" name="openord">
    <input type="hidden" name="TYPE" value="Submitted the regular ol' way">
    <input type="hidden" name="NAME" value="Frederick Q. Larson">
    <input type="submit" name="TASK" value="Submit with Javascript" onclick='submitorder();'>
    <input type="submit" name="TASK" value="Normal Submit">
</form>
</body>
</html>

Click the “Normal Submit” and you’ll see a value for TASK like this:

The contents of $_REQUEST are:
array(3) {
  ["TYPE"]=>
  string(29) "Submitted the regular ol' way"
  ["NAME"]=>
  string(19) "Frederick Q. Larson"
  ["TASK"]=>
  string(13) "Normal Submit"
}

Not so with the “Submit with Javascript” button:

The contents of $_REQUEST are:
array(2) {
  ["TYPE"]=>
  string(26) "Submitted using javascript"
  ["NAME"]=>
  string(19) "Frederick Q. Larson"
}

In IE and FF, when clicking “Submit with Javascript” you see:

The contents of $_REQUEST are:
array(3) {
  ["TYPE"]=>
  string(26) "Submitted using javascript"
  ["NAME"]=>
  string(19) "Frederick Q. Larson"
  ["TASK"]=>
  string(22) "Submit with Javascript"
}

Any idea why Chrome is having a problem with this?

  • 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-06T03:35:00+00:00Added an answer on June 6, 2026 at 3:35 am

    If all you want is to submit the form with a parameter changed through JavaScript, then

    function submitorder() {
        document.openord.TYPE.value='Submitted using javascript';
    }
    

    is sufficient, because the form will automatically be submitted when the user clicks on the submit button.

    “Correct” behaviour

    According to the Specification, section “4.10.22.4 Constructing the form data set”:

    The algorithm to construct the form data set for a form form optionally in the context of a submitter submitter is as follows. If not specified otherwise, submitter is null.
    . . .
    3. Loop: For each element field in controls, in tree order, run the following substeps:
        1. If any of the following conditions are met, then skip these substeps for this element:
        . . .
        •   The field element is a button but it is not submitter.

    This algorithm is used when a form is submitted (specification reference).
    Apparently, since no button was clicked, the submitter is empty, hence no submit element.

    In Firefox, the button which initiates the function which submits the form seems to be flagged submitter. Calling the function without a (form submit) button shows the same behaviour as in Chrome: http://jsfiddle.net/3fwcr/1/.

    When event.preventDefault(); is added to the button’s click event, then the form also submits as in Chrome: http://jsfiddle.net/3fwcr/2/.
    Apparently, Firefox’ default submission is still triggered, even though the form is already being submitted (seems to be against the specification: “If form is already being submitted (..), then abort these steps” (“these steps” = form submission)).

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

Sidebar

Related Questions

Possible Duplicate: JavaScript post request like a form submit I have a value calculated
I have a form with JavaScript validation. Upon there being an error, the submit
I have a select field within a form: <form id=myform> <select id=value onchange=javascript: document.myform.submit()>
I would like to use replace the value of a submit button with Loading&hellip;
jQuery(document).ready(function(){ $(#button).submit(function() { { var email_id=document.getElementById('textfield').value; var password=document.getElementById('textfield2').value; var utype=document.getElementById(utype).value; var url=login_check.jsp?&email_id=+encodeURIComponent(email_id)+&password=+encodeURIComponent(password)+&utype=+encodeURIComponent(utype); $('form').get(0).setAttribute('action',url); alert(document.form1.action);
I have a select box that needs to submit it's value to a server
Here is the JavaScript function ChangeVol(id) { document.form.selectFS_devId.value = id; document.form.selectFS_currentNameSpace.value = ; document.form.submit();
I have a form containing only select fields, a submit button and a reset
Using Visual Studio 2010, MVC project When my form is submitted (currently via javascript,
I detect a form submit on an 'addrecord' button being pressed, and then I

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.