Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-18-2011, 03:01 AM   PM User | #1
vearn
New to the CF scene

 
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
vearn is an unknown quantity at this point
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.
vearn is offline   Reply With Quote
Old 11-18-2011, 03:00 PM   PM User | #2
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
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
alykins is offline   Reply With Quote
Old 11-18-2011, 06:48 PM   PM User | #3
Dom Mv
New Coder

 
Join Date: Sep 2011
Location: England
Posts: 39
Thanks: 2
Thanked 0 Times in 0 Posts
Dom Mv is an unknown quantity at this point
As far as I am aware, what you are asking is not possible.
Dom Mv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:32 AM.


Advertisement
Log in to turn off these ads.