• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

how to call different java script codes on different button click

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic