Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Convert this script to work in html?

    Hi, i'm a new to programming. I try to convert this script which me and my friend
    create in Eclipse to work in HTML webpage. Till now, still no success. Any web-dev can help me?



    import javax.swing.*;
    import java.text.*;
    public class InputItem {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    String [] namaBarang=new String[5];
    String [] kodBar=new String[5];
    double [] hargaBarang=new double[5];
    DecimalFormat df= new DecimalFormat("#.##");
    namaBarang [0] = "Sunsilk";
    namaBarang [1] = "Dove";
    namaBarang [2] = "Gardenia";
    namaBarang [3] = "Ferero Rocher";
    namaBarang [4] = "Wall's ice cream";

    kodBar [0] = "123";
    kodBar [1] = "456";
    kodBar [2] = "789";
    kodBar [3] = "014";
    kodBar [4] = "852";

    hargaBarang [0] =9.85 ;
    hargaBarang [1] =5.95 ;
    hargaBarang [2] =2.35 ;
    hargaBarang [3] =5.35 ;
    hargaBarang [4] =1.25 ;

    int option = 0;
    String output="";
    double total=0.0;

    output+= "----------------------------\n\tMy Mydin\n----------------------------\n\n";
    while (option==JOptionPane.YES_NO_OPTION)
    {
    String codeStr=JOptionPane.showInputDialog(null,"Enter the barcode :");
    String qtyStr=JOptionPane.showInputDialog(null,"Enter the quantity :");

    int qty = Integer.parseInt(qtyStr);


    System.out.println("\n\n");
    for( int i=0; i<kodBar.length;i++)
    {
    if(codeStr.equalsIgnoreCase(kodBar[i]))
    {
    output+="\n"+ namaBarang [i]+"----------RM"+df.format((hargaBarang[i]*qty));
    total+=(hargaBarang[i]*qty);
    }
    }

    option=JOptionPane.showConfirmDialog(null, "Continue?");
    }
    output+="\n\n============RM"+df.format(total);

    JOptionPane.showMessageDialog(null, output);
    }

    }


    Any help greatly appreciated.

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,711
    Thanks
    41
    Thanked 191 Times in 190 Posts
    you absolutely cannot convert a server side script to HTML... if you are trying to make a javascript function based off of this java function it might be possible, but I do not know the limitations of javascript... I assume it would be more than do-able since you can write to the document... either way this needs to be moved

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #3
    New Coder
    Join Date
    Sep 2011
    Location
    England
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts
    As far as I am aware, what you are asking is not possible.


  •  

    Posting Permissions

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