aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes how to call different java script codes on different button click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to call different java script codes on different button click" Watch "how to call different java script codes on different button click" New topic
Author

how to call different java script codes on different button click

Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
hi...
Is there a way that i can do the following
if(docuemnt.formname.button1.clicked)
{
execute these java script codes}
else if(document.formname.button2.clicked)
{
//execute these java script codes
}
Why i want to do this is coz i have these two forms which are displayed on button clicks..one Add form and One Edit form ... I have this Submit button to submit the request of the user .....whose name changes dynamically according the selection of the ADD/ Edit button . Both the Add and Edit button are also submit buttons.
When i click on the Add button the submit button name changes to Add_submit and when i click on te Edit button the submit button name changes to Edit_submit.... so is there a way that the javascript validations that i have put on the text feilds be called respectively on the click of only the Add_submit or Edit_submit button and not the ADD/ Edit button which are basically used just for displaying the respective tables..
Eg:
------------------
function check(this)
{
if(document.formname.Add_submit.clicked)
{
// textbox1 and textbox2 not to be left empty
}
else if(document.forname.Edit_submit.clicked)
{
// textbox3 and textbox4 not to be left empty
}
}
and then can this function be called ... from the FORM tag...???
<form name ="request" method="POST" onSubmit = "return check(this)">
----------------------------------
Please provide suggestions with code
Thanxs in advance
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
why don't you just add onclick handlers to the buttons and call the function that way. Then you will know what button called the function.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to call different java script codes on different button click