• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Diffterent action from different button

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all ,

I have a jsp page in my project that has 10 button & i want to perform different action from different button .

how can i do this . please provide some code .

Thanks ,
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi rathi,
Can you please eloborate bit more on the problem. because for doing ten diff. things you can call ten diff. javascript functions on onclick of the buttons, or you can call a single function with ten different parameters.....
It all depends on your problem ..........

---------------
Kalai Selvan T.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One button will add 'name'( that user will enter ) in the database .
One button will delete 'name' from the database .
One button will add somthing in combobox as well as database also .

Like that .
I hope now it will be clear to u .
Thanks
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Plz any body post the answer .
Thanks
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I think ur using the yahoo mail id. ur Problem is like clicking the forward, reply, reply all, Send, Buttons .

So u can copy the javascript code and check the functionality and add it to ur code.

I think It works .
Or Simple assign a variable a value and in java script check for the variable and pass the parameter(URL) according to the request
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do that with 2 methods. You make links or images(with links) in the place of buttons. like this for example



And you give each link an action. In the test.jsp you get the parametrs via <% String action = request.getParameter("action") %> then the following:

if ( action .equals("delete")){
..
..// delete code

}else if (action .equals("add")){
..
..
}

The second way to do this is to make for each button (action) a form. For example a form for the add action, en the action schould be action="test.jsp?action=add"

I hope this help you.

Azzeddine
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi rathi,

i have a pattern soln for ur problem, so u try it out with the following code by changing variable with reference to ur application. so u r telling u have 10 buttons. so most probably u have to use this for 10 times or u can simplify by writing java script using some loops.

refer this code sample.




add the html statement in body of ur html code or form tag of u html code and

write the java script in head section of the html as given below


function validation()
{

//Flag for checking for Submiting the FORM for Saving or Not
var flgSub="0";

var ictr = 0;
var c1 = "";//variable for checking whether Check box checked or not.

for(ictr=0;ictr<(document.forms[0].elements.length)-1;ictr=ictr+1)
{
//Checkbox
c1=document.forms[0].elements[ictr].checked;
//alert("Chk box name = "+ document.forms[0].elements[ictr].name +" value = "+c1);
if (c1==true)
{
flgSub = "1";
}
}

if (flgSub=="1")
{
var confirmok = false;
confirmok = window.confirm("Do you want to send payslip throug E-mail?");
if (confirmok == true)
{
document.forms[0].method="post";
document.forms[0].target="";
document.forms[0].action="createallpdf.jsp";
document.forms[0].submit();
}


}
else
{
alert(" Sorry ! No Records Selected to submit");
}
}

try it with this .like this i have used for my problem and it as solve.

have a nice time
with regards
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic