View Single Post
  #1 (permalink)  
Old 12th January 2009, 15:28
lifeform lifeform is offline
D4PHP User
 
Join Date: Jun 2007
Location: Naples, FL
Posts: 40
lifeform is on a distinguished road
Default Getting calling component in JS

Hi everyone. I have a form with 50 comboboxes, and I need to call essentially the same function in the Javascript OnChange event. I could duplicate the same code fifty times but I'm way too lazy for that. .

The problem I'm having is that I can't seem to discover the component that called the function.

To illustrate the issue, I've created a simple function as follows, and configured the OnChange JS event in each of the comboboxes to call it (the comboboxes are called cbo1, cbo2...cbo50):
PHP Code:
function cboJSChange($sender, $params)
{
?>
      var calledfrom = "<?php echo($sender->Name); ?>";
      alert(calledfrom);
<?php
}
This works fine for the first component, and I get an alert box with cbo1 in it.

The problem is that the alert also says cbo1 when I change cbo2, and cbo3 etc.

How can I discover which component called the JS function?
__________________
If it was too easy it would be no fun
Reply With Quote
Sponsored Links