Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do identify which button they pressed in same sub? 1

Status
Not open for further replies.

jfdabiri

MIS
Feb 27, 2007
282
US
hi,
i have an hta app that has 2 buttons. basically they both do the same thing (execute a query from an oracle db). if they press "sort by name" button or "sort by unit" button, i want to execute the same sub. but i like to be able to know what button they pushed. how can this be done in vbscript (check button id? button name? or something?)
thanks.
 
Inside the onclick handler (or any event handler for this matter), you can identify the source element which the event is triggered. From the reference of it (oelem hereinbelow), you can check its name or id whichever more convenient.
[tt]
set oelem=window.event.srcElement
alert(oelem.id & vbcrlf & oelem.name)
[/tt]
You can see the mechanism in action in a recent thread I posted an example (where the op there is not at the par to understand it.) dilettante has another elaboration there too.

Risk of doing more than necessary, you can sure pass the id/name as an argument to the handler. Acceptable but conceptually less illustrative.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top