• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to call different java script codes on different button click

 
Rekha Pande
Ranch Hand
Posts: 145
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic