...

View Full Version : Convert this script to work in html?



vearn
11-18-2011, 04:01 AM
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.

alykins
11-18-2011, 04:00 PM
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

Dom Mv
11-18-2011, 07:48 PM
As far as I am aware, what you are asking is not possible.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum