Delphi For PHP Forums       


Go Back   Delphi-PHP Forums > Programming > Javascript and Ajax
Forum Jump Register FAQ Members List Downloads Search Today's Posts Mark Forums Read

Javascript and Ajax Questions and information about working with Ajax and Javascript in Delphi for PHP.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12th January 2009, 14:28
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12th January 2009, 17:20
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,272
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

Might have to tweak it some but wouldn't the same thing from dbrepeater work?

Get a row value form dbrepeater
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12th January 2009, 17:32
D4PHP User
 
Join Date: Jun 2007
Location: Naples, FL
Posts: 40
lifeform is on a distinguished road
Default

Thanks, as always, 405hp. Yes, that was the clue.

Here's how it works:

PHP Code:
function cboJSChange($sender, $params) 

?> 
      var calledfrom = event.target || event.srcElement;
      alert(calledfrom); 
<?php 
}
Simple, when you know how...
__________________
If it was too easy it would be no fun
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 23:08.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright © 2004 - 2009, G&J Solutions Ltd. All Rights Reserved. terms of use