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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:49:03+00:00 2026-05-18T12:49:03+00:00

I have this form in HTML: <form action=# method=post> <label for=label-id>id</label> <input type=text name=id

  • 0

I have this form in HTML:

<form action="#" method="post">
    <label for="label-id">id</label>
    <input type="text" name="id" id="label-id" />
    <label for="label-name">Name</label>
    <input type="text" name="name" id="label-name" />
    <label for="label-description">Description</label>
    <input type="text" name="description" id="label-description" />
    <input type="reset" value="Cancel" />
    <input type="submit" value="Update" />
</form>

There are no values in it, because I set the values with jQuery (AJAX call to a backend system) in this way:

$('#label-id').val(data.id);
$('#label-name').val(data.name);
$('#label-description').val(data.description);

So, if I press the input type=”reset” button, all values are empty. But I want, that pressing on the button the values which I set with the three lines above in jQuery should be there.

For example.
The AJAX call gives me the data id=12, name=”test”, description=”my desc”, the values are set to the text input fields and I see these values. Now someone is changing name=”test” to “test123″. Pressing on the reset button, the value should be name=”test” instead of “test123”.

How can I do this?

Thank you in advance & Best Regards.

  • 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-18T12:49:04+00:00Added an answer on May 18, 2026 at 12:49 pm

    You can set the defaultValue attribute/property for each <input> element, so when the reset button is pushed, all elements are reset to that defined default value:

    $('#label-id').val(data.id)[0].defaultValue = data.id;
    $('#label-name').val(data.name)[0].defaultValue = data.name;
    $('#label-description').val(data.description)[0].defaultValue = data.description;
    

    Working demo: http://jsfiddle.net/AndyE/NDahF/

    nb: you can just use .attr("defaultValue", value) in place of [0].defaultValue, but it’s not quite as efficient.

    Also note that defaultValue applies only to text elements. If you have other types of field you can handle the <form> element’s onreset event to re-apply the defaults to selects, checks, radios, etc.

    $('form').bind("reset", function () {
        $('#label-id').val(data.id);        
        $('#label-name').val(data.name);
        $('#label-description').val(data.description);
        $('#label-someselect').val(data.someSelectValue);
    
        // Cancel the default action
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this html <ul> <li><form action=# name=formName></li> <li><input type=text name=someName /></li> <li><input type=text
I have this HTML dropdown: <form> <input type=text id=realtxt onkeyup=searchSel()> <select id=select name=basic-combo size=1>
My form.html <form id=search-form method=post action=. name=f> <p><label for=id_customer_type>Customer type</label> <select name=customer_type id=id_customer_type> <option
<form id=login_frm method=post action = /login/user_auth/> <fieldset> <legend>Login:</legend> <label for=id_email>Email</label> <input type=text name=email id=id_email
I've got a form: <form action=# method=post id=hubForm> <label class=labelText>Expiration Date:</label> <input class=datBox type=text
I have a form with the following HTML below: <form id=course_edit_form name=course_form action=/courses/save method=post>
I have the following form: <html> <body> <form action=upload_file.php method=post enctype=multipart/form-data> <label for=file>Filename:</label> <input
I have a html form with the data by this post method 'form id='form1'
I created this form: <form method=post action=process-form.php id=emailForm name=emailForm target=_self> <h4>Sign up to be
hello i have a form like this <form id=ricerca enctype=application/x-www-form-urlencoded method=post action=><table class=inserisci_modifica> <tr

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.