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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:09:17+00:00 2026-05-21T15:09:17+00:00

my HTML code: <form action=Generator.klx method=post onsubmit=genarate(‘hiddenField’)> <input type=hidden id=hiddenField name=hidden value=/> <input type=submit

  • 0

my HTML code:

<form action="Generator.klx" method="post" onsubmit="genarate('hiddenField')">
   <input type="hidden" id="hiddenField" name="hidden" value=""/>
   <input type="submit" name="submit"/>
</form>

my JavaScript:

function genarate(hiddenField){
  var field = document.getElementById(hiddenField);
  field.value = "new Value";
 }

But it just didnot work :(. Can anybody tell me where I was wrong?

Thank you

  • 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-21T15:09:18+00:00Added an answer on May 21, 2026 at 3:09 pm

    Your code as quoted should be working, and does in my tests with a variety of browsers. (I’ve tried it locally, with a POSTed form, but you can also try it here: http://jsbin.com/ehoro4/1 I’ve changed the method to GET so you can see the result in the URL.)

    My guess is that you have something else on the page with the name or id “hiddenField”, other than just the hidden field you’ve quoted. If you change the name of the field to “fluglehorn” or something else that’s (um) unlikely to be elsewhere on your page, it may well work. That’s because the namespace used by getElementById is (sadly) quite crowded.

    Alternately, are you sure that genarate is appearing at global scope? (E.g., it’s outside of all other functions.) Because your onsubmit attribute requires that genarate be global. So this works:

    <form action="#" method="get" onsubmit="genarate('hiddenField')">
       <input type="hidden" id="hiddenField" name="hidden" value=""/>
       <input type="submit" name="submit"/>
    </form>
    <script>
    function genarate(hiddenField){
      var field = document.getElementById(hiddenField);
      field.value = "new Value";
    }
    </script>
    

    but for example this would not:

    <form action="#" method="get" onsubmit="genarate('hiddenField')">
       <input type="hidden" id="hiddenField" name="hidden" value=""/>
       <input type="submit" name="submit"/>
    </form>
    <script>
    (function() { // Begin scoping function to avoid global symbols (not uncommon)
        function genarate(hiddenField){
          var field = document.getElementById(hiddenField);
          field.value = "new Value";
        }
    })();
    </script>
    

    Also recommend using a debugger (there’s no excuse for not using client-side debuggers here in 2011) to set a breakpoint on the genarate function and walk through, to see what’s going wrong.

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

Sidebar

Related Questions

I am trying to generate such HTML <form action=/some/process method=post> <input type=hidden name=foo.a value=aaa/>
I have the following code in a form's submit button onClickListener: String action, user,
I have a page where I am getting session values then calling form action
I've been having some 'issues' with the admin generator (Propel version). The HTML generation
I nave this pice of code in index.html (upload controller) This an example. <p>
I'm following this article ( http://asciicasts.com/episodes/160-authlogic ), I'm not using nifty generator tho. I've
i am trying to do a simple form that adds a new comment using
How can I open a new window through javascript when popup is blocked in
I seem to have a problem that I can't find the solution for myself,
Trying to recreate { script/generate scaffold }, and I've gotten thru a number 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.