Results 1 to 4 of 4
  1. #1
    Anis is offline Member
    Join Date
    May 2012
    Posts
    2
    Rep Power
    0

    Unhappy pass multiple button value on same action but different data..?

    hello..im new in java..im just confused..how can we know which button is click to display in the next page..?
    for example..when i click PackageA button,it will display Package A details,when i click PackageB button,it will display Package B details..
    tq...





    Package.jsp


    <Script LANGUAGE="JavaScript">

    function button1()
    {
    document.booking.username.value = "Package A"
    booking1.submit()
    }
    function button2()
    {
    document.booking.username.value = "Package B"
    booking2.submit()
    }
    function button3()
    {
    document.booking.username.value = "Package C"
    booking3.submit()
    }

    </Script>

    <form name="booking1" action="bookingform.jsp" method="post">


    </dl>
    <input name="username" type="hidden" id="packageid" value="Package A"/>
    <input type="submit" name="book1" value="Book Now!" onClick="button1()"></input>
    </li></div></form>

    <form name="booking2" action="bookingform.jsp" method="post">


    </dl>
    <input name="username" type="hidden" id="packageid" value="PACKAGE B" />
    <input type="submit" name="book2" value="Book Now!" onClick="button2()"></input>

    </li></div></form>
    <form name="booking3" action="bookingform.jsp" method="post">


    <input name="username" type="hidden" id="packageid" value="PACKAGE C" />
    <input type="submit" name="book3" value="Book Now!" onClick="button3()"></input>

    </li></div>
    </form>

    bookingform.jsp


    <%

    String id = (String)session.getAttribute("packageid");
    String id2 = request.getParameter("packageid");
    String pid="";
    String pname = "";
    String pprice = "";
    String pact1 = "";
    String pact2 = "";
    String pact3 = "";
    String pact4 = "";
    String pact5 = "";

    try{


    Statement st2=conn.createStatement();
    ResultSet rs2=st2.executeQuery("SELECT * FROM PACKAGE WHERE PACKAGE_ID= '"+ id2 +"' ");

    while(rs2.next()){
    pid= rs2.getString(1);
    pname = rs2.getString(2);
    pprice = rs2.getString(3);
    pact1 = rs2.getString(4);
    pact2 = rs2.getString(5);
    pact3 = rs2.getString(6);
    pact4 = rs2.getString(7);
    pact5 = rs2.getString(8);
    }

    }catch(Exception e1)
    {}
    %>

  2. #2
    Art Vandelay is offline Member
    Join Date
    May 2012
    Posts
    18
    Rep Power
    0

    Default Re: pass multiple button value on same action but different data..?

    Looks like another one of the java to javascript is like ham to apples posts, expect it to get locked by admin soon.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: pass multiple button value on same action but different data..?

    Off topic. Find a JavaScript forum.

    db

    edit: On review, this question may be related to JSP. Reopened the thread and moved to the appropriate section.
    Last edited by DarrylBurke; 05-31-2012 at 07:03 PM. Reason: Moved and reopened thread
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: pass multiple button value on same action but different data..?

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 2
    Last Post: 12-11-2011, 11:44 PM
  2. Action button HELP?
    By utoptas in forum New To Java
    Replies: 3
    Last Post: 08-27-2010, 11:40 PM
  3. pass value to action.do struts
    By munish in forum Web Frameworks
    Replies: 1
    Last Post: 11-13-2009, 03:58 PM
  4. pass value to action.do struts
    By munish in forum Web Frameworks
    Replies: 1
    Last Post: 11-13-2009, 03:51 PM
  5. Please help on Button action
    By michaelxiao in forum New To Java
    Replies: 4
    Last Post: 04-24-2009, 11:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •