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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:45:55+00:00 2026-05-19T01:45:55+00:00

I am trying to work out how to post the id and value of

  • 0

I am trying to work out how to post the id and value of a new keyword changed inside a row with an input field.

I basically do a mysql query to collect rows of keywords, i then display the keyword inside an input field with a save button next to it. If you click Save i want to post the id and new keyword value for that row.

I can only get the first row to work, a friend helped me with the jquery for getting id only but can i modify to get keyword value too?

MY HTML/PHP

<?php
$sql = "SELECT * FROM Tags ORDER BY name";
$result = mysql_query($sql);

while ($row = mysql_fetch_array($result)) {
$id      = $row['id'];
$keyword = $row['name'];
?>

<tr id="<?php echo $id;?>"> 

<td><?php echo $id;?></td>

<td><?php echo $keyword;?></td>

<td><input type="text" name="keyword" id="newkeyword" value="<?php echo $keyword;?>"><a class="savenewkeyword" >Save</a></td>

<td><a id="deleteKeyword">x</a></td>

</tr>

<?php } ?>

MY JAVASCRIPT

$('table td .savenewkeyword').click(function(){

var id = $(this).parent().parent().attr('id');   
var name = $('input#newkeyword').attr('id'); 
data = 'id=' + id + '&name=' + name; 
var parent = $(this).parent().parent(); 

$.ajax(  
{
type: "POST", 
url: "update/updatekeyword.php",   
data: data,
cache: false,
success: function()
{
parent.fadeOut('slow');
parent.fadeIn('slow');
}

});
});

So just to recap, im trying to post id and new keyword value for each row.

Any help would be much appreciated.

Also happy new year for soon 😉

John

SOLVED – Thank you DSKVR and Cybermate 😉

<script type="text/javascript" charset="utf-8">

$('table td .savenewkeyword').click(function(){
var id = $(this).parents('tr').attr('id');   
var name = $('input#newkeyword', $(this).parent()).attr('value'); 
data = 'id=' + id + '&name=' + name; 
var parent = $(this).parent().parent(); 

$.ajax({
        type: "POST", 
        url: "update/updatekeyword.php",   
        data: data,
        cache: false,
        success: function()
        {
        parent.fadeOut('slow');
        parent.fadeIn('slow');
        }

    });
});


</script>
  • 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-19T01:45:55+00:00Added an answer on May 19, 2026 at 1:45 am

    Two Things,

    • you need to grab the value from the input, not the id.

      switch var name = $('input#newkeyword').attr('id'); with var name = $('input#newkeyword').attr('value');

    • you should use .parents('tr') instead of .parent().parent(), while they both work, one is easier to understand without referencing the HTML from the javascript.

    Hope this helps, suggested edits illustrated below.


    $('table td .savenewkeyword').click(function(){
    var id = $(this).parents('tr').attr('id');   
    var name = $('input#newkeyword').attr('value'); 
    data = 'id=' + id + '&name=' + name; 
    var parent = $(this).parent().parent(); 
            
    $.ajax({
            type: "POST", 
            url: "update/updatekeyword.php",   
            data: data,
            cache: false,
            success: function()
            {
            parent.fadeOut('slow');
            parent.fadeIn('slow');
            }
            
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out how this DropDownListFor works but with no success.
Okay, I'm trying to make a quick little class to work as a sort
I'm doing something a bit strange here, I'm querying data out of my local
I'm trying to add dynamic content to my mvc application. I'm using Steven Sanderson
i'm quite new with php. i think this is quite straight forward but i'm
I am trying to update status on twitter using twitter4j. Everything works fine on
Sorry, I am still new using jquery so this might be an easy question.
Interesting problem. In a project scope change, I broke one application into two applications.
I'm fighting with creation of several forms in MS Access 2007. I accomplished the

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.