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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:14:02+00:00 2026-05-23T18:14:02+00:00

I have a small form and I need jquery to clear the hidden form

  • 0

I have a small form and I need jquery to clear the hidden form value after the form has been submitted.

Here is a snippet from my form

<select id='size'>
    <option value='4.99'>S</option>
    <option value='5.99'>M</option>
    <option value='6.99'>L</option>
    <option value='7.99'>XL</option>
</select>

<input type="hidden" id="my-item-price" name="my-item-price" value="" />

and the jquery which changes the hidden field value

$(document).ready(function(){

    $('#size').change(function() {

        var x= $(this).val();
        $('#my-item-price').val(x);
    });
}

the problem is once I have submitted the form, I want the value to be erased from the hidden input. I expect that i have to set the value to "" but how do I do it?


EDIT -:

Here is a link to a testing part of my site

What I want to do is once the button is clicked, it resets the hidden form value to nothing so when i make a new selection, it changes the value again

Here is the code for the jquery.

    function clearoption() {
            alert('it should work');
            $('#my-item-price').attr('value','');
        }

        $('#size').change(function() {

            var x= $(this).val();
            $('#my-item-price').val(x);
        }); 

      // Add an item to the cart
      $('.jcart').submit(function(e) {
         add($(this));
         clearoption();
         e.preventDefault();
      });

It’s calling the function to clear the #my-item-price but for some reason it’s not doing it. If i make a different size selection it still adds the original price

  • 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-23T18:14:03+00:00Added an answer on May 23, 2026 at 6:14 pm

    If you are using Ajax to submit the form then in the success part, you can use following code

     $(' #myform input:hidden').attr('value','');
    

    or

    $('#my-item-price').attr('value','');
    

    else if u r not using ajax for submitting form then clearing hidden fields wont make sense.

    also, it would be a lot easier if u can post link to your page!

    EDIT:
    To trigger/update the change to the

    tag where the price is displayed, you need to do following:

    $(' #myform input:hidden').attr('value','').trigger('change');
    

    I think this should work

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

Sidebar

Related Questions

Hii , I have a small php form. I need it to come in
I have a small jQuery plugin that I use for form AJAX validation. There
I have a small form inside a table. POSTing that form creates a new
In my c# application i have this small form which is used to set
I have a very small form where a user can enter their zip code
I have a small contact form: <form method=post action=contact.php name=contactform id=contactform> <fieldset> <legend>Please fill
I want to globalize my application. I have created a small form which asks
I have defined a small DSL that is mostly written in the form of
Post-release, I have made one small change to one form in our development site
I'm developing a small POS for a university project. I have a form which

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.