hai all,

i want to convert indian rupees into words, is there any function in javascript or any useful links
are appreciated..

how to convert indian rupees to words

for ex
234.45=Two hundred thirty four rupees and fourty five paise only.

this want for any number upto billions..

have you done anything so far ?

if pls post here so taht we are here to help you

@radhakrishna my page code is .....

<%@ page import="java.sql.*"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.*"%>
<%!int val;
 String slno;
 Connection con;
 Statement st;

 %>
 <%
 try
 {
 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 con=DriverManager.getConnection("jdbc:odbc:k","hindustan","hindustan");
 st=con.createStatement();
 ResultSet rs=st.executeQuery("select count(*) from voucher where type='Payment'");

    while (rs.next())
    {
    val=rs.getInt(1);
    }
    val=val+1;
    slno="PMT"+val;
 }
 catch(Exception e)
 {
    e.printStackTrace();
 }
 %>

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<script language="javaScript" type="text/javascript" src="calendar.js"></script>

   <link href="calendar.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Receipt voucher</title>
<script language ="javascript">

function showMe(id) 
{ 

var obj = document.getElementById(id);

    obj.style.visibility = "visible";
    document.rv.cd.value="";
    document.rv.bn.value="";
    document.rv.cn.value="";
    document.rv.ba.value="";
    document.rv.ac.value="";
    document.rv.ach.value="";


}

function showMe1(id) 
{ 

var obj = document.getElementById(id);

    obj.style.visibility = "hidden";
    document.rv.cd.value="NIL";
    document.rv.cn.value="NIL";
    document.rv.bn.value="NIL";
    document.rv.ba.value="NIL";
    document.rv.ac.value="NIL";
    document.rv.ach.value="NIL";

}



function chqvalidate()

{
    if (document.rv.cd.value=="")
    {
        alert("Enter Cheque Date(dd/mm/yyyy)");

        document.rv.cd.select();
        document.rv.cd.focus();
    }
    else if (document.rv.cn.value=="")
    {
        alert("Enter Cheque No");
        document.rv.cn.select();
        document.rv.cn.focus();
    }

    else if (document.rv.bn.value=="")
    {
        alert("Enter Bank Name");
        document.rv.bn.select();
        document.rv.bn.focus();
    }
    else if (document.rv.ba.value=="")
    {
        alert("Enter Bank Address");
        document.rv.ba.select();
        document.rv.ba.focus();
    }
    else if (document.rv.ac.value=="")
    {
        alert("Enter A/C No");
        document.rv.ac.select();
        document.rv.ac.focus();
    }
    else if(document.rv.ach.value=="")
    {
        alert("Enter A/C Holder Name");
        document.rv.ach.select();
        document.rv.ach.focus();
    }
}

function callme1()

{

    if(document.rv.action1[0].checked==true)
    {
    var action1=document.rv.action1[0].value;
    //Landlord
    document.rv.action1[0].checked=true;
    rv.action="paymentvoucher.jsp?action1="+action1;
    rv.submit();

    }

    else if(document.rv.action1[1].checked==true)
    {
    var action1=document.rv.action1[1].value;
    //Agency
    document.rv.action1[1].checked=true;
    rv.action="paymentvoucher.jsp?action1="+action1;
    rv.submit();

    }
    else
    {
    var action1=document.rv.action1[2].value;
    //Customer
    document.rv.action1[2].checked=true;
    rv.action="paymentvoucher.jsp?action1="+action1;
    rv.submit();

    }
}
function setstatus()

{
    var dd=document.rv.ddd.value;

    if(dd=="Landlord")
    {
    document.rv.action1[0].checked=true;    
    }
    else if(dd=="Agency")
    {
        document.rv.action1[1].checked=true;

    }
    else
    {
        document.rv.action1[2].checked=true;

    }
}

function callme2()

{
    var mainval=document.rv.D1.value;

    var mainval1=mainval.split("--");
    var mainval2=mainval1[0];

    document.rv.T4.value=mainval2;
    document.rv.T3.value=mainval1[1];
}


//Division Visible/Invisible


function callme()
    {
         if (document.rv.datum2.value=="")    
    {
    alert("Voucher Date can not Null"); 
    document.rv.datum2.select;
    document.rv.datum2.focus;

    }
     else if (document.rv.T3.value=="")   
    {
    alert("Party Code can not be Null");
    document.rv.T3.focus();
    }
     else if (document.rv.T4.value=="")   
    {
    alert("Party Name can not be Null");
    document.rv.T4.focus();
    }
    else if (document.rv.T5.value=="")   
    {
    alert("Plese Enter Amount");
    document.rv.T5.focus();
    }
else
        {
    rv.action="PaymentVoucher";
    rv.submit();
        }
    }
</script>

</head>

<body style="background-image:url('pic/beach-red-sepia-design.jpg')" onload="setstatus()">
<form name="rv" method="post" >

<div align="center">
    <table border="1" width="62%" bgcolor="#33CCFF" id="table1">
        <tr>
            <td colspan="4">
            <p align="center"><b><font size="6" face="AR CENA">Payment Voucher</font></b></td>
        </tr>
        <tr>
            <td width="20%"><b>Voucher No</b></td>
            <td width="22%"><b><input type="text" name="T1" size="12" style="background-color:yellow ;font-family:Arial Black; font-size: 10pt; color: #800000" size="12" align=center value="<%=slno%>" readonly ></b></td>
            <td width="16%"><b>Voucher Date</b></td>

    <%!Date d=null;
       String Display=null;
    %>
            <%
                d=new Date();
    int month=d.getMonth()+1;
    int day= d.getDate();
    int year=d.getYear()+1900;

    //SimpleDateFormat pd=new SimpleDateFormat("mmm/dd/yyyy");
    Display=day+"-"+month+"-"+year;

    %>
            <td width="37%"><input type="text" name="datum2" value="<%=Display%>" size="13" title="Select Date from Picker" readonly>
            <a href ="#" onClick="setYears(2000, 2020); showCalender(this, 'datum2');"><img src="calender.png"></a>
            </td>
        </tr>
        <tr>

<%

String action1=request.getParameter("action1");
if(action1==null||action1.equals(""))
{
action1="Landlord";
}
else if(action1==null||action1.equals(""))
{
action1="Customer";
}
else
{
    action1=request.getParameter("action1");

}

%>

        <input type="hidden" name="ddd" value="<%=action1%>">
            <td width="20%"><b>Type</b></td>
            <td width="76%" colspan="3">
            <input type="radio" value="Landlord" name="action1" onclick="callme1()">Landlord
            <input type="radio" value="Agency" name="action1" onclick="callme1()">Agency
            <input type="radio" value="Customer" name="action1" onclick="callme1()">Customer
             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <select size="1" name="D1" onchange="callme2()"><option>Select</option>

<%
if(action1.equals("Customer"))
{
String query1="select cust_id,comp_name from customer order by comp_name" ;
System.out.println(query1+";;;;;;;;;;;;;;");
ResultSet rs1=st.executeQuery(query1);
while(rs1.next())
{
    String code=rs1.getString(1);
    String name1=rs1.getString(2);


    String mainval=name1+"--"+code;
    %>
<option value=<%=mainval%>><%=mainval%></option>
<%
}
    }
    else
    {
String query1="select cr_code,name1  from creditor where type='"+action1+"' order by name1" ;
System.out.println(query1+";;;;;;;;;;;;;;");
ResultSet rs1=st.executeQuery(query1);
while(rs1.next())
{
    String code=rs1.getString(1);
    String name1=rs1.getString(2);


    String mainval=name1+"--"+code;
    %>
<option value=<%=mainval%>><%=mainval%></option>
<%
}
    }

%>

        </select></td>
        </tr>
        <tr>
            <td width="20%"><b>Party Code</b></td>
            <td width="22%"><input type="text" name="T3" size="12" style="background-color:#CCCCCC ;font-family:Comic Sans MS; font-size: 10pt; color: #000080" readonly></td>
            <td width="16%"><b>Party Name</b></td>
            <td width="37%">
            <input type="text" name="T4" size="29" style="background-color:#CCCCCC ;font-family:Comic Sans MS; font-size: 10pt; color: #000080" readonly></td>
        </tr>

        <tr>
            <td width="20%"><b>Mode of Payment</b></td>
            <td width="76%" colspan="3">
            <input type="radio" name="R1" value="Cash" onclick=showMe1('div1') >Cash
            <input type="radio" name="R1" value="Cheque" onclick=showMe('div1') checked>Cheque<div id="div1">
                <table border="0" width="101%" id="table1">
    <tr>
        <td colspan="4" bgcolor="#FFFF66">
        <p align="center"><font face="Bradley Hand ITC" color="#808000"><b>
        Cheque Details</b></font></td>
    </tr>
    <tr>
        <td width="15%"><font face="Goudy Old Style" size="2">Cheque</font><font face="Goudy Old Style" size="2"> 
        Date</font></td>
        <td width="22%"><input type="text" name="cd" size="11" title="Select Date from Picker" readonly><a href="#" onClick="setYears(1974, 2020);
       showCalender(this, 'cd');">
      <img src="calender.png"></a></td>
        <td width="21%"><font size="2" face="Goudy Old Style">Bank Name</font></td>
        <td width="38%"><input type="text" name="bn" size="25"></td>
    </tr>
    <tr>
        <td width="15%" height="24"><font face="Goudy Old Style" size="2">Cheque</font><font face="Goudy Old Style" size="2"> 
        No</font></td>
        <td height="24" width="22%"><input type="text" name="cn" size="13"></td>
        <td height="24" width="21%"><font size="2" face="Goudy Old Style">Bank 
        Address</font></td>
        <td width="38%" height="24"><input type="text" name="ba" size="25"></td>
    </tr>
    <tr>
        <td width="15%"><font size="2" face="Goudy Old Style">A/C No.</font></td>
        <td width="22%"><input type="text" name="ac" size="14"></td>
        <td width="21%"><font size="2" face="Goudy Old Style">A/C Holder Name</font></td>
        <td width="38%"><input type="text" name="ach" size="25"></td>
    </tr>

</table></div></td>
        </tr>
        <tr>
            <td width="20%"><b>Amount</b></td>
            <td width="76%" colspan="3"><input type="text" name="T5" size="12" onclick="chqvalidate()"></td>
        </tr>
        <tr>
            <td width="20%"><b><i>Amount in words</i></b></td>
            <td width="76%" colspan="3"><input type="text" name="T6" size="67"></td>
        </tr>
        <tr>
            <td width="97%" colspan="4">
            <p align="center">
            <input type="submit" value="Save" name="B1" style="width: 60; font-size: 12pt; font-family: Zurich Lt BT; color: #008000; text-decoration: blink; font-style: italic; height: 25" onclick="callme()" >
            <input type="reset" value="Reset" name="B2"></td>
        </tr>
    </table>
</div>
</form>
</center>
<!-- Calender Script  --> 

    <table id="calenderTable">
        <tbody id="calenderTableHead">
          <tr>
            <td colspan="4" align="center">
              <select onChange="showCalenderBody(createCalender(document.getElementById('selectYear').value,
               this.selectedIndex, false));" id="selectMonth">
                  <option value="0">Jan</option>
                  <option value="1">Feb</option>
                  <option value="2">Mar</option>
                  <option value="3">Apr</option>
                  <option value="4">May</option>
                  <option value="5">Jun</option>
                  <option value="6">Jul</option>
                  <option value="7">Aug</option>
                  <option value="8">Sep</option>
                  <option value="9">Oct</option>
                  <option value="10">Nov</option>
                  <option value="11">Dec</option>
              </select>
            </td>
            <td colspan="2" align="center">
                <select onChange="showCalenderBody(createCalender(this.value, 
                document.getElementById('selectMonth').selectedIndex, false));" id="selectYear">
                </select>
            </td>
            <td align="center">
                <a href="#" onClick="closeCalender();"><font color="#003333" size="+1">X</font></a>
            </td>
          </tr>
       </tbody>
       <tbody id="calenderTableDays">
         <tr style="">
           <td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td>
         </tr>
       </tbody>
       <tbody id="calender"></tbody>
    </table>

<!-- End Calender Script  -->
</body>

</html>

@radhakrishna my modify page code is .....
plz help me...

<%@ page import="java.sql.*"%>
<%@ page import="java.text.*"%>
<%!int val;
 String slno;
 Connection con;
 Statement st;

 %>


<html>

<head>   
<title>Receipt voucher</title>
<script language ="javascript">


</script>

</head>

<body style="background-image:url('pic/beach-red-sepia-design.jpg')" onload="setstatus()">
<form name="rv" method="post" >

<div align="center">
    <table border="1" width="62%" bgcolor="#33CCFF" id="table1">
        <tr>
            <td colspan="4">
            <p align="center"><b><font size="6" face="AR CENA">Payment Voucher</font></b></td>
        </tr>
        <tr>
            <td width="20%"><b>Party Code</b></td>
            <td width="22%"><input type="text" name="mod" size="12" style="background-color:#CCCCCC ;font-family:Comic Sans MS; font-size: 10pt; color: #000080" ></td>
            <td width="16%"><b>Party Name</b></td>
            <td width="37%">
            <input type="text" name="T4" size="29" style="background-color:#CCCCCC ;font-family:Comic Sans MS; font-size: 10pt; color: #000080"></td>
        </tr>

        <tr>
            <td width="20%"><b>Mode of Payment</b></td>
            <td width="76%" colspan="3">
            <div id="div1">
                <input type="text" name="T7" size="12" onclick="chqvalidate()"></div></td>
        </tr>
        <tr>
            <td width="20%"><b>Amount</b></td>
            <td width="76%" colspan="3"><input type="text" name="T5" size="12" onclick="chqvalidate()"></td>
        </tr>
        <tr>
            <td width="20%"><b><i>Amount in words</i></b></td>
            <td width="76%" colspan="3"><input type="text" name="T6" size="67"></td>
        </tr>
        <tr>
            <td width="97%" colspan="4">
            <p align="center">
            <input type="submit" value="Save" name="B1" style="width: 60; font-size: 12pt; font-family: Zurich Lt BT; color: #008000; text-decoration: blink; font-style: italic; height: 25" onclick="callme()" >
            <input type="reset" value="Reset" name="B2"></td>
        </tr>
    </table>
</div>
</form>
</center>
</body>

</html>

@ radhakrishna! Not working in my page...Will you suggest me.How my page code will be..

i used the same script by doing one example

here is that example and its work great

<html>
<head>
<title>welcome to Convert Currency In Words(http://pandiyachendur.blogspot.in/2009/11/javascript-to-convert-indian-

rupees-in.html)</title>


<script type="text/javascript">


function test_value() {
    var junkVal=document.getElementById('rupees').value;
    junkVal  = Math.floor(junkVal);
    var obStr = new String(junkVal);
    numReversed= obStr.split("");
    actnumber=numReversed.reverse();

    if(Number(junkVal) >=0){
        //do nothing
    }
    else{
        alert('wrong Number cannot be converted');
        return false;
    }
    if(Number(junkVal)==0){
        document.getElementById('container').innerHTML=obStr+''+'Rupees Zero Only';
        return false;
    }
    if(actnumber.length>9){
        alert('Oops!!!! the Number is too big to covertes');
        return false;
    }

    var iWords=["Zero", " One", " Two", " Three", " Four", " Five", " Six", " Seven", " Eight", " Nine"];
    var ePlace=['Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', ' 

Nineteen'];
    var tensPlace=['dummy', ' Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety' ];

    var iWordsLength=numReversed.length;
    var totalWords="";
    var inWords=new Array();
    var finalWord="";
    j=0;
    for(i=0; i<iWordsLength; i++){
        switch(i)
        {
        case 0:
            if(actnumber[i]==0 || actnumber[i+1]==1 ) {
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            inWords[j]=inWords[j];
            break;
        case 1:
            tens_complication();
            break;
        case 2:
            if(actnumber[i]==0) {
                inWords[j]='';
            }
            else if(actnumber[i-1]!=0 && actnumber[i-2]!=0) {
                inWords[j]=iWords[actnumber[i]]+' Hundred and';
            }
            else {
                inWords[j]=iWords[actnumber[i]]+' Hundred';
            }
            break;
        case 3:
            if(actnumber[i]==0 || actnumber[i+1]==1) {
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            if(actnumber[i+1] != 0 || actnumber[i] > 0){
                inWords[j]=inWords[j]+" Thousand";
            }
            break;
        case 4:
            tens_complication();
            break;
        case 5:
            if(actnumber[i]==0 || actnumber[i+1]==1 ) {
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            inWords[j]=inWords[j]+" Lakh";
            break;
        case 6:
            tens_complication();
            break;
        case 7:
            if(actnumber[i]==0 || actnumber[i+1]==1 ){
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            inWords[j]=inWords[j]+" Crore";
            break;
        case 8:
            tens_complication();
            break;
        default:
            break;
        }
        j++;
    }

    function tens_complication() {
        if(actnumber[i]==0) {
            inWords[j]='';
        }
        else if(actnumber[i]==1) {
            inWords[j]=ePlace[actnumber[i-1]];
        }
        else {
            inWords[j]=tensPlace[actnumber[i]];
        }
    }
    inWords.reverse();
    for(i=0; i<inWords.length; i++) {
        finalWord+=inWords[i];
    }
        return finalWord;
}

function convert_amount_into_rupees_paisa(){
        var finalWord1 = test_value();
        var finalWord2 = "";

        var val = document.getElementById('rupees').value;
        var actual_val  = document.getElementById('rupees').value; 
        document.getElementById('rupees').value = val;

        if(val.indexOf('.')!=-1)
       {
              val = val.substring(val.indexOf('.')+1,val.length);
              if(val.length==0 || val.length=='00'){
                 finalWord2 = "zero paisa only";
              }
              else{
               document.getElementById('rupees').value = val;
               finalWord2 = test_value() + " paisa only";
              }
             document.getElementById('container').innerHTML=finalWord1 +" Rupees and "+finalWord2;
       }
       else{
             //finalWord2 =  " Zero paisa only";
             document.getElementById('container').innerHTML=finalWord1 +" Rupees Only";
       }
    document.getElementById('rupees').value = actual_val;   
}
</script>
<head>
<body>

Enter Amount :<input type="text" name="rupees" value="" id="rupees" /> <br/>
Amount in Words : <br>
<div id="container" style="height:50px;width:500px;background-color: lightgreen">
.................................
</div>

<input type="button" name="button1" value="Get In Words"  onclick="convert_amount_into_rupees_paisa() " /><br/>

</body>
</html>

check it once and change the code accordingly as your requirement

(what i mean is filed name of the amount, where to display the amount in words and calling the javascript method in your code)

thats it

Note: not tested for all the possible user inputs but its giving your actual output upto some extent

@ radhakrishna! I was testing this code in EditPlus. Showing Error message "Unterminated string constand on Line-31, char-124. and it is not converting...

please replace following code in your script code what we had so far (in the given example ).

i just made some changes to this method

function convert_amount_into_rupees_paisa(){
        var finalWord1 = test_value();
        var finalWord2 = "";

        var val = document.getElementById('rupees').value;
        var actual_val  = document.getElementById('rupees').value; 
        document.getElementById('rupees').value = val;

        if(val.indexOf('.')!=-1)
       {
              val = val.substring(val.indexOf('.')+1,val.length);
              if(val.length==0){
    finalWord2 = "";
    document.getElementById('container').innerHTML=finalWord1 +" Rupees Only"+finalWord2;
              }
              else{
                  document.getElementById('rupees').value = val;
                  if(val != '00'){                      
                      finalWord2 = test_value() + " paisa only";
                      document.getElementById('container').innerHTML=finalWord1 +" Rupees and "+finalWord2;
                  }else{           
                      finalWord2 = "";
                      document.getElementById('container').innerHTML=finalWord1 +" Rupees only"+finalWord2;
                  }
              }

       }
       else{
             //finalWord2 =  " Zero paisa only";
             document.getElementById('container').innerHTML=finalWord1 +" Rupees Only";
       }
    document.getElementById('rupees').value = actual_val;   
}

check it and let me know the status

i found that syntax error in my script code (what i have posted so far in this blog )

Syntax Error : reasons

keep this ePlace array values in a single line as follows (while posting this code into here the values are jumped to another line that gives the above syntax error )

var ePlace=['Ten',' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', 'Nineteen'];

so keep the array values in sigle line and test it

it works fine on my side

let me know the status

happy coding

Not working... :(
Will you write the total page code for me.

Many many thanks...radhakrishna.p .Now it working...

Hi,
I'm looking for a script to display amount in words.
I found your blog & try it.
But found a bug in this script..
It display "One Crore Lakh Rupees Only" when enter "10000000" amount. It should be "One Crore Rupees Only".

hai Xitij,

great to here and nicely found the bug.thanks alot to you for that

just now i changed the code to fix that bug

here is the modified version of the code

<html>
<head>
<title>welcome to Convert Currency In Words(http://pandiyachendur.blogspot.in/2009/11/javascript-to-convert-indian-rupees-in.html)</title>

<script type="text/javascript">


function test_value() {
    var junkVal=document.getElementById('rupees').value;
    junkVal  = Math.floor(junkVal);
    var obStr = new String(junkVal);
    numReversed= obStr.split("");
    actnumber=numReversed.reverse();

    if(Number(junkVal) >=0){
        //do nothing
    }
    else{
        alert('wrong Number cannot be converted');
        return false;
    }
    if(Number(junkVal)==0){
        document.getElementById('container').innerHTML=obStr+''+'Rupees Zero Only';
        return false;
    }
    if(actnumber.length>9){
        alert('Oops!!!! the Number is too big to covertes');
        return false;
    }

    var iWords=["Zero", " One", " Two", " Three", " Four", " Five", " Six", " Seven", " Eight", " Nine"];
    var ePlace=['Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', 'Nineteen'];
    var tensPlace=['dummy',' Ten',' Twenty',' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety' ];

    var iWordsLength=numReversed.length;
    var totalWords="";
    var inWords=new Array();
    var finalWord="";
    j=0;
    for(i=0; i<iWordsLength; i++){
        switch(i)
        {
        case 0:
            if(actnumber[i]==0 || actnumber[i+1]==1 ) {
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            inWords[j]=inWords[j];
            break;
        case 1:
            tens_complication();
            break;
        case 2:
            if(actnumber[i]==0) {
                inWords[j]='';
            }
            else if(actnumber[i-1]!=0 && actnumber[i-2]!=0) {
                inWords[j]=iWords[actnumber[i]]+' Hundred and';
            }
            else {
                inWords[j]=iWords[actnumber[i]]+' Hundred';
            }
            break;
        case 3:
            if(actnumber[i]==0 || actnumber[i+1]==1) {
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            if(actnumber[i+1] != 0 || actnumber[i] > 0){ //here
                inWords[j]=inWords[j]+" Thousand";
            }
            break;
        case 4:
            tens_complication();
            break;
        case 5:
            if(actnumber[i]=="0" || actnumber[i+1]==1 ) {
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            if(actnumber[i+1] != 0 || actnumber[i] > 0){   //here 
                inWords[j]=inWords[j]+" Lakh";
            }

            break;
        case 6:
            tens_complication();
            break;
        case 7:
            if(actnumber[i]=="0" || actnumber[i+1]==1 ){
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            if(actnumber[i+1] != 0 || actnumber[i] > 0){ // changed here
                inWords[j]=inWords[j]+" Crore";
            }
            break;
        case 8:
            tens_complication();
            break;
        default:
            break;
        }
        j++;
    }

    function tens_complication() {
        if(actnumber[i]==0) {
            inWords[j]='';
        }
        else if(actnumber[i]==1) {
            inWords[j]=ePlace[actnumber[i-1]];
        }
        else {
            inWords[j]=tensPlace[actnumber[i]];
        }
    }
    inWords.reverse();
    for(i=0; i<inWords.length; i++) {
        finalWord+=inWords[i];
    }
        return finalWord;
}

function convert_amount_into_rupees_paisa(){
        var finalWord1 = test_value();
        var finalWord2 = "";

        var val = document.getElementById('rupees').value;
        var actual_val  = document.getElementById('rupees').value; 
        document.getElementById('rupees').value = val;

        if(val.indexOf('.')!=-1)
       {
              val = val.substring(val.indexOf('.')+1,val.length);
              if(val.length==0 || val.length=='00'){
                 finalWord2 = "zero paisa only";
              }
              else{
               document.getElementById('rupees').value = val;
               finalWord2 = test_value() + " paisa only";
              }
             document.getElementById('container').innerHTML=finalWord1 +" Rupees and "+finalWord2;
       }
       else{
             //finalWord2 =  " Zero paisa only";
             document.getElementById('container').innerHTML=finalWord1 +" Rupees Only";
       }
    document.getElementById('rupees').value = actual_val;   
}
</script>
<head>
<body>

Enter Amount :<input type="text" name="rupees" value="" id="rupees" /> <br/>
Amount in Words : <br>
<div id="container" style="height:50px;width:500px;background-color: lightgreen">
.................................
</div>

<input type="button" name="button1" value="Get In Words"  onclick="convert_amount_into_rupees_paisa() " /><br/>

</body>
</html>

check it once and let me know

i want a code for converting indian amount to words with rupees and paise in core java

    thank you very mouch...friend. working wel...

I was supposed to create an invoice sample as web page so i need to convert total to word without clicking any button please help me for this

Mail:harishc4599@gmail.com

i want to output like that i means in a text box not in div without click on any button

Amount: <input type="text" name="amount1" id="totalAmount" pattern="[0-9]+" title="please enter amount" id="Account No: ">
Amount in Words: <input type="text" name="amount_string" id="amount_string" size="0">

You have resurrected a dead thread with a post that does not bear much in common with the original post. Maybe you'd be best to start your own thread.

function Rs(amount){
var words = new Array();
words[0] = 'Zero';words[1] = 'One';words[2] = 'Two';words[3] = 'Three';words[4] = 'Four';words[5] = 'Five';words[6] = 'Six';words[7] = 'Seven';words[8] = 'Eight';words[9] = 'Nine';words[10] = 'Ten';words[11] = 'Eleven';words[12] = 'Twelve';words[13] = 'Thirteen';words[14] = 'Fourteen';words[15] = 'Fifteen';words[16] = 'Sixteen';words[17] = 'Seventeen';words[18] = 'Eighteen';words[19] = 'Nineteen';words[20] = 'Twenty';words[30] = 'Thirty';words[40] = 'Forty';words[50] = 'Fifty';words[60] = 'Sixty';words[70] = 'Seventy';words[80] = 'Eighty';words[90] = 'Ninety';var op;
amount = amount.toString();
var atemp = amount.split(".");
var number = atemp[0].split(",").join("");
var n_length = number.length;
var words_string = "";
if(n_length <= 9){
var n_array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0);
var received_n_array = new Array();
for (var i = 0; i < n_length; i++){
received_n_array[i] = number.substr(i, 1);}
for (var i = 9 - n_length, j = 0; i < 9; i++, j++){
n_array[i] = received_n_array[j];}
for (var i = 0, j = 1; i < 9; i++, j++){
if(i == 0 || i == 2 || i == 4 || i == 7){
if(n_array[i] == 1){
n_array[j] = 10 + parseInt(n_array[j]);
n_array[i] = 0;}}}
value = "";
for (var i = 0; i < 9; i++){
if(i == 0 || i == 2 || i == 4 || i == 7){
value = n_array[i] * 10;} else {
value = n_array[i];}
if(value != 0){
words_string += words[value] + " ";}
if((i == 1 && value != 0) || (i == 0 && value != 0 && n_array[i + 1] == 0)){
words_string += "Crores ";}
if((i == 3 && value != 0) || (i == 2 && value != 0 && n_array[i + 1] == 0)){
words_string += "Lakhs ";}
if((i == 5 && value != 0) || (i == 4 && value != 0 && n_array[i + 1] == 0)){
words_string += "Thousand ";}
if(i == 6 && value != 0 && (n_array[i + 1] != 0 && n_array[i + 2] != 0)){
words_string += "Hundred and ";} else if(i == 6 && value != 0){
words_string += "Hundred ";}}
words_string = words_string.split(" ").join(" ");}
return words_string;}
function RsPaise(n){
nums = n.toString().split('.')
var whole = Rs(nums[0])
if(nums[1]==null)nums[1]=0;
if(nums[1].length == 1 )nums[1]=nums[1]+'0';
if(nums[1].length> 2){nums[1]=nums[1].substring(2,length - 1)}
if(nums.length == 2){
if(nums[0]<=9){nums[0]=nums[0]*10} else {nums[0]=nums[0]};
var fraction = Rs(nums[1])
if(whole=='' && fraction==''){op= 'Zero only';}
if(whole=='' && fraction!=''){op= 'paise ' + fraction + ' only';}
if(whole!='' && fraction==''){op='Rupees ' + whole + ' only';} 
if(whole!='' && fraction!=''){op='Rupees ' + whole + 'and paise ' + fraction + ' only';}
amt=document.getElementById('amt').value;
if(amt > 999999999.99){op='Oops!!! The amount is too big to convert';}
if(isNaN(amt) == true ){op='Error : Amount in number appears to be incorrect. Please Check.';}
document.getElementById('op').innerHTML=op;}}
RsPaise(Math.round(document.getElementById('amt').value*100)/100);

Thank you
Gokarna

commented: -1 for no attribution. -3

The above script has been copied from (I think) https://finotax.com/misc/rs-in-words

Why couldn't you just provide the link? Did you want it to look like you wrote it? At least give the author some attribution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.