Results 1 to 2 of 2

Thread: Calculte TextBox example TextBox Calculations help

  1. #1
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Calculte TextBox example TextBox Calculations help

    demo.rsjoomla.com/calculation-form-example

    TextBox Calculations
    html code
    Code:
    <div class="componentheading">{global:formtitle}</div>
    {error}
    <table border="0">
    	<tr class="rsform-block rsform-block-field1">
    		<td>{field1:caption}</td>
    		<td>{field1:body}<div class="formClr"></div>{field1:validation}</td>
    		<td>{field1:description}</td>
    	</tr>
    	<tr class="rsform-block rsform-block-field2">
    		<td>{field2:caption}</td>
    		<td>{field2:body}<div class="formClr"></div>{field2:validation}</td>
    		<td>{field2:description}</td>
    	</tr>
    	<tr class="rsform-block rsform-block-calculate">
    		<td>{Calculate:caption}</td>
    		<td>{Calculate:body}<div class="formClr"></div>{Calculate:validation}</td>
    		<td>{Calculate:description}</td>
    	</tr>
    	<tr class="rsform-block rsform-block-total">
    		<td>{Total:caption}</td>
    		<td>{Total:body}<div class="formClr"></div>{Total:validation}</td>
    		<td>{Total:description}</td>
    	</tr>
    </table>
    javascript code
    Code:
    function calculateText(){
     
    var op1=document.getElementById('field1');
     
    var op2=document.getElementById('field2');
     
    var result=document.getElementById('Total');
     
    if(op1.value=="" || op1.value!=parseFloat(op1.value)) op1.value=0;
     
    if(op2.value=="" || op2.value!=parseFloat(op2.value)) op2.value=0;
     
    result.value=0;
     
    result.value=parseInt(result.value);
     
    result.value=parseInt(result.value)+parseInt(op1.value)+parseInt(op2.value);}

    How do I
    5x7 =35
    35x1.5$
    result:52.5$

    field1 x field2 hidden = ?? x 1.5
    total : 00

    please help me

  2. #2
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Replace last three lines of code with this one. Actually we have to explicitly convert field value to numbers

    result.value = Number(op1.value) + Number(op2.value);

Similar Threads

  1. Replies: 0
    Last Post: 09-09-2009, 09:02 AM
  2. textbox help
    By Rino5555 in forum MySQL and other databases
    Replies: 1
    Last Post: 05-01-2008, 08:57 PM
  3. Replies: 2
    Last Post: 01-16-2008, 09:32 AM
  4. Replies: 2
    Last Post: 06-10-2007, 08:45 AM
  5. Asp textbox
    By gugu in forum ASP
    Replies: 3
    Last Post: 05-03-2006, 05:40 AM

Bookmarks

Posting Permissions

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