Results 1 to 2 of 2
  1. #1
    sally mally is offline Member
    Join Date
    Nov 2013
    Posts
    14
    Rep Power
    0

    Default how to create a javascript

    please help me.
    i dont know how to create a javascript on my coding to calcutate the redeem points minus the total price
    when click on the radio button it will minus the total of price

    here my codes:

    redeempoints.jsp

    <%@ page import="stall.menu.Menu" %>
    <%@ page import="order.OrderDetails" %>
    <%@ page import="java.util.Vector" %>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <%@ page import="stall.menu.MemberController" %>
    <%@ page import="stall.menu.Member" %>

    <%@ page import="order.OrderDetails" %>
    <%@ page import="java.util.Vector" %>



    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>payment type</title>
    <script type="text/javascript" src="js/form.js"></script>
    <style type="text/css">
    </head>
    body {
    background-color: #FFF;
    }
    .Tablebalance {
    background-color: #6CC;
    color: #000;
    font-style: normal;
    font-weight: bold;
    }
    </style>
    <script type="text/javascript">
    function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_findObj(n, d) { //v4.01
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }


    </script>
    </head>

    <body onload="MM_preloadImages('pay2.png','cancel2.png', 'cash.jpg','home.jpg','confirm2.png','points.png', 'member.jpg','aa2.png')">

    <table width="100%" height="350" border="0">
    <tr>
    <td><p><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','home.jpg',1)" ><img src="s.png" name="home" width="100" height="100" border="1" id="home" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('pay','','cash.jpg',1)"> <img src="cash2.png" name="pay" width="100" height="100" border="1" id="pay" /></a><a href="paymenttype.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('a','','aa2.png',1)"><im g src="aa.png" name="a" width="110" height="88" border="0" align="right" id="a" /></a></p>
    <p>&nbsp;</p>
    <table width="60%" border="0" align="center">

    <%

    /* Get membership id to search from the searchmember.jsp and
    parse to int for ease of life */
    int membershipId = Integer.parseInt(request.getParameter("id"));

    /* Encapsulate in a member object - not to violate OO principle */
    Member memberToSearch = new Member();
    memberToSearch.setMembershipId(membershipId);

    /* Get result from database */

    try {
    MemberController memberCtrl = new MemberController();
    memberToSearch = memberCtrl.selectMember(memberToSearch);

    } catch (Exception e) {
    out.print(e.getMessage());
    }


    %>


    <tr>
    <td width="28%" height="538" align="center" valign="top" bgcolor="#FFFFFF"><fieldset>
    <strong>
    <legend>ORDER SUMMARY</legend>
    </strong>

    <%

    OrderDetails dummy1 = new OrderDetails();
    Menu item = new Menu();
    item.setMenuId(7);
    dummy1.setOrderItem(item);
    dummy1.setQuantity(1);
    dummy1.setSubTotal(10.0d);

    Vector<OrderDetails> dummies = new Vector<OrderDetails>();
    dummies.add(dummy1);


    Vector<OrderDetails> orderItems = dummies;
    double subTotal = 0.00d;
    double total = 0.00d;
    double tax = 0.00d;

    for (OrderDetails items:orderItems) {
    %>

    <p><input type="text" name="textfield" id="textfield" value=" <%= items.getQuantity()%> <%=items.getOrderItem().getName() %> RM <%= items.getSubTotal() %>" readonly/>
    <input type="hidden" name="id" value="<%= memberToSearch.getMembershipId() %>" />

    <%

    subTotal += items.getSubTotal();
    tax = subTotal * 0.1;
    total = subTotal + tax;

    }
    %>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p><strong>TOTAL</strong></p>
    <form id="form1" name="form1" method="post" action="">
    <p><strong>
    <input type="text" name="textfield4" id="textfield7" value=" RM <%= total %>" onclick="getRedeemPoints" readonly/>
    </strong></p>
    </form>

    </fieldset></td>
    <td width="66%"><table width="100%" border="1" align="center" class="Tablebalance">
    <tr align="center">
    <%
    int id = Integer.parseInt(request.getParameter("id"));
    MemberController memberCtrl = new MemberController();
    Member member = new Member();
    member.setMembershipId(id);
    member = memberCtrl.selectMember(member);

    %>

    <td><strong>Current Points :</strong></td>
    <td><form id="form3" name="form3" method="post" action="">
    <strong>
    <input type="text" name="textfield6" id="textfield9" value="<%=member.getPoint() %>" />
    </strong>
    </form></td>
    </tr>
    </table>

    <body onload='hideTotal()'>
    <div id="wrap">
    <form action="" id="points" onsubmit="return false;">
    <div>
    <div class="cont_order">
    </div>
    </div>

    <table width="100%" height="381" border="0">
    <tr align="center">
    <td valign="middle" bgcolor="#FFFFFF"><table width="100%" border="1" align="center">
    <tr bgcolor="#CCCCCC">
    <td align="center" valign="middle"><strong>POINTS</strong></td>
    </tr>

    <td>

    <label class='radiolabel'><input type="radio" name="selectedpoints" value="100 POINTS" onclick="calculateTotal()" />
    100 POINTS (RM2.00)</label>
    <br/>
    <label class='radiolabel'><input type="radio" name="selectedpoints" value="200 POINTS" onclick="calculateTotal()" />
    200 POINTS (RM 4.00)</label>
    <br/>
    <label class='radiolabel'><input type="radio" name="selectedpoints" value="300 POINTS" onclick="calculateTotal()" />
    300 POINTS (RM 6.00)</label>
    <br/>
    <label class='radiolabel'><input type="radio" name="selectedpoints" value="400 POINTS" onclick="calculateTotal()" />
    400 POINTS (RM 8.00)</label>
    <br/>
    <label class='radiolabel'><input type="radio" name="selectedpoints" value="500 POINTS" onclick="calculateTotal()" />
    400 POINTS (RM 8.00)</label>
    <br/>
    <br />
    </td>
    </body>
    </form></td>
    </tr>
    </table></td>
    </tr>
    </table>


    <map name="Map" id="Map">
    <area shape="poly" coords="102,11" href="#" />
    </map>
    </body>
    </html>

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: how to create a javascript

    These are the Java forums. Java and JavaScript are completely different animals.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Replies: 3
    Last Post: 02-11-2013, 07:57 PM
  2. Replies: 10
    Last Post: 09-03-2012, 08:13 PM
  3. Replies: 0
    Last Post: 05-09-2011, 10:02 AM
  4. Problem--How to create dynamic tree structure in jsp using javascript
    By natu in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-11-2010, 08:11 AM
  5. create Instance of class in Javascript
    By TDMaster in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-09-2009, 04:26 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
  •