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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:33:07+00:00 2026-05-29T15:33:07+00:00

My question is! I am copying content from one table to another table and

  • 0

My question is! I am copying content from one table to another table and when I am doing this I need the function name to change to talentselect instead of driverselect which is attached to each table row. I still need to keep the variable values to parse. Just wondering if anyone can help me with this. I know that I should be binding the events to the elements with Jquery and not using OnClick but for now I need a solution to achieve this with the OnClicks.

Many Thanks!

The copying of the table

<table id="driverselectiontable" cellspacing="0">
<tr class="chosen" onclick="return driverselect(this, value, value);">
<td>driver</td></tr>
<tr class="odd" onclick="return driverselect(this, value, value);">
<td>driver</td></tr>
<tr class="even" onclick="return driverselect(this, value, value);">
<td>driver</td></tr>
<tr class="chosen" onclick="return driverselect(this, value, value);">
<td>driver</td></tr>
<tr class="even" onclick="return driverselect(this, value, value);">
<td>driver</td></tr>
</table>

<table id="talentselectiontable" cellspacing="0">
</table>


$("#talentselectiontable").html($("#driverselectiontable .chosen").clone(true).attr("class","odd"));

So basically I am copying all of the table rows that have the class named “chosen” but upon doing so I need to change the function call name to “talentselect”. But each row in the table has different parameters being parsed which is allocated with PHP.

I have tried this piece of code but it is not working still

$("#talentselectiontable tr").attr("onclick").replace("driverselect", "talentselect");
  • 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-29T15:33:08+00:00Added an answer on May 29, 2026 at 3:33 pm

    I can’t see the actual HTML of your table, so this may be slightly incorrect, but should get you started.

    $("#talentselectiontable tr").attr("onclick", "return talentselect(this, value, value);");
    

    This whole problem would actually be a lot easier if you used event handlers rather than inline onclick attributes. You could then use the jQuery live() function (see http://api.jquery.com/live/) that would mean that JQuery would take care of changing the function for you. Your solution would look something like this:

    $("#driverselectiontable tr").live('click', driverselect);
    $("#talentselectiontable tr").live('click', talentselect);
    

    And then whatever code to ensure that your cloning code gets called.

    Edit: In response to the comment, it looks like this is what you’re after:

    var clickval = $("#talentselectiontable tr").attr("onclick");
    $("#talentselectiontable tr").attr("onclick", clickval.replace('driverselect', 'talentselect'));
    

    That should get you going.

    With a view to better JavaScript practice however, I would recommend another approach entirely. Rather than storing your parameter values in the ‘onclick’ attribute, store them in a data attribute. So your HTML would look something like this:

    <table id="driverselectiontable" cellspacing="0">
    <tr class="chosen" data-myparam1="value" data-myparam2="value"><td>driver</td></tr>
    

    And so on. You can then use JQuery to parse the values:

    function driverselect() {
        var row = $(this),
            param1 = row.attr('data-myparam1'),
            param2 = row.attr('data-myparam2');
    
        // rest of the code goes here
    
    }
    

    Your markup will be cleaner, and you can use the live() jQuery functionality as described above.

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

Sidebar

Related Questions

I had a requirement to copy all fields from one form to another similar
This question is somewhat similar to this one Best way to deploy large *.war
I'm actually just copying an old question from railsforum as he asked it back
Following on from a previous question I had here : Copying a string from
If my understanding of deep and shallow copying is correct my question is an
Sorry if answers to this question already exist, I did not find them yet.
Note: This question is similar to How to prevent the copy of XML documentation
I know this is a noob question, but I've worked with Python before and
I'm somewhat new to C++ so, I guess this is a very basic question.
with reference of this question Sort json array I have the following JSON String

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.