Dynamic onClick and passing a parameter to the function??

Posted on 2006-10-22
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) { = 'btnSave' + currentRow; = '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 250 total points
ID: 17783511

function editFunction(editButton, currentRow, someId) { = 'btnSave' + currentRow; = '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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript object functions help 1 19
Triple line in an alert message 4 24
Table style position to the left 8 26
close pop up windows when logout or main window closes 17 55
In Part 1 ( we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

726 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