Dynamic onClick and passing a parameter to the function??

Posted on 2006-10-22
Medium Priority
Last Modified: 2008-01-09

I am trying to change the onClick of this button dynamically.  Initially the button says "edit", when you click "edit" I redefine some of the properties of the button

function editFunction(currentRow, someId) {
       editButton.id = 'btnSave' + currentRow;
      editButton.name = 'btnSave' + currentRow;
      editButton.value = 'Save';
      editButton.onclick = saveFunction;


function saveFunction(someId) {

Hope that makes sense, basically I am just trying to get the variable which is passed into editFunction() to be available to the saveFunction.

Question by:Westside2004
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

daohailam earned 1000 total points
ID: 17783511

function editFunction(editButton, currentRow, someId) {
     editButton.id = 'btnSave' + currentRow;
     editButton.name = 'btnSave' + currentRow;
     editButton.value = 'Save';
     editButton.onclick = function() { saveFunction(someId); }

function saveFunction(someId) {

<input id="btnEdit" type="button" name="btnEdit" value="Edit" onclick="editFunction(this, curRow, selId)"/>

Author Comment

ID: 17808036


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question