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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:14:23+00:00 2026-06-13T07:14:23+00:00

I have a form , with a couple of <input> tags inside. I have

  • 0

I have a form, with a couple of <input> tags inside. I have a submit button (actually an <input> of type BUTTON, not SUBMIT) that is outside the form. I have the form set up similar to this —

<form name="testform" id="testform" action="test.jsp" onsubmit="return modify_value();" method="POST">
<input name="test1" id="test1" type="TEXT" value="A"/>
<input name="test2" id="test2" type="TEXT" value="B"/>
<input name="test3" id="test3" type="HIDDEN"/>
</form>

The submit button, which is outside the form, is defined this way —

<input type="BUTTON" id="_submit" onclick="document.forms[0].submit();"/>

And the modify_value() JavaScript method looks like this —

function modify_value()
{
    var hidden_field = document.getElementById('test3');
    hidden_field.value = 'new_test_value_set_on_clicking';
    return true;
}

When the submit button is clicked, I am trying to modify the value of the test3 element before the form gets submitted. For some reason, I can never read the new value in my servlet.

Alternate Method – (Doesn’t Work Either) WORKS!

I have tried submitting the form in a slightly different way as well – by setting the button’s onclick event to point to the modify_value() method and in the last line of that method, calling form.submit() instead of returning a value (EDIT: And of course, removing the onsubmit attribute in the form). This doesn’t work either.

What am I doing wrong here?

  • 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-13T07:14:23+00:00Added an answer on June 13, 2026 at 7:14 am

    you can try this

    <input type="BUTTON" id="_submit" onclick="modify_value()"/>
    function modify_value()
    {
        var hidden_field = document.getElementById('test3');
        hidden_field.value = 'new_test_value_set_on_clicking';
        document.getElementById("testform").Submit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with couple of input fields and i want a script
I have come across couple of similar answers for my question in this form,
I have a couple of problems. I'm creating a form inside a table, from
I have a form that I generate new input fields to with javascript and
I have couple of JSP pages in my application with couple of input tags
I have this input in a form: <input type=text value=<script src='/js/script.js' type='text/javascript'></script> name=embed/> The
I have a form with an input text field which imports data every couple
I have an input form that allows me to insert a new quiz into
I have an input form with a column on the left that contains the
I have a form with two combo boxes and couple of buttons. One of

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.