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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:28:18+00:00 2026-06-07T13:28:18+00:00

I have code that allows a field to be edited via a input thats

  • 0

I have code that allows a field to be edited via a input thats hidden/shown when a button is clicked. It works fine but it only locally changes the data on the page(no updates to my database. Which means when a user edits their profile its saved on the database). I know how to submit a form without a refresh using jquery but I don’t understand how to combine the two so someone can edit a field(in place) and then when they click done it submits it without a refresh(like facebook).

The issue is using the code below the ‘edit’ button(which is just a anchor) turns into ‘save’ button then back into ‘edit’. I thought for me to submit the field, I need the button to be a submit button?

Here’s the code I’m using to do the in place editing:

$('#editvalue').click(function(e){$('#storedvalue').hide();$('#altervalue').show();});
$('#savevalue').click(function(e){
   var showNew = $('#changevalue').val();
   $('#altervalue').hide();
   $('#storedvalue').show();
   $('#storedvalue span').text(showNew);
});

And I learned how to submit a form without a refresh from here a tutorial. I’m not sure how to combine them for the effect I want but I’m not sure if this is even the right way to approach the problem. Is there a way take the showNew variable and submit it as a post without the user clicking a submit button(maybe triggered when the user clicks save)?

I’m super new to jquery and web programming so sorry if I’m not explaining this right. If it helps here’s the html that works with the js code above:
PHP jQuery Example:

<div id="wrapper">
   <div id="container">
      <div id="storedvalue"><span>Hello</span> [<a href="javascript:void(0);" id="editvalue">edit</a>]</div>
      <div id="altervalue" style="display:none;"><input type="text" name="changevalue" id="changevalue" value="Hello"> [<a href="javascript:void(0);" id="savevalue">save</a>]</div>
   </div>
</div>
  • 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-07T13:28:20+00:00Added an answer on June 7, 2026 at 1:28 pm

    If I understand you correctly, simply do an AJAX post as described at http://api.jquery.com/jQuery.post/ inside your $(‘#savevalue’).click(function(e){…})` function. something like this:

    $('#editvalue').click(function(e){$('#storedvalue').hide();$('#altervalue').show();});
    $('#savevalue').click(function(e){
        var showNew = $('#changevalue').val();
        $('#altervalue').hide();
        $.post("test.php", { val: showNew } );
        $('#storedvalue').show();
        $('#storedvalue span').text(showNew);
    });
    

    This would post the single field to the test.php page. You can (and should) add success/failure callbacks aswell to see if everything went as expected.

    Of course, this value will have to be handled on the PHP side for the rest.

    EDIT: example with more generic code, including html generation at http://jsfiddle.net/X8Rsg/4/

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

Sidebar

Related Questions

I have the following code that allows my console app to go to the
We currently have some php code that allows an end user to update records
I have a small code that allows me to add custom name to a
I have created a text field component with an 'x' button inside that will
I have the following simple Javascript code that allows only digits to be entered
is there any development environments that allow you to have one code base that
I have a need to allow my users to execute .NET code that they
I have code that looks like this: template<class T> class list { public: class
I have code that I want to look like this: List<Type> Os; ... foreach
I have code that uses Win API function RegSaveKeyEx to save registry entries to

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.