0

i want to inset my javascript id in to the place of input value .

if i give Interest name input value="100"

how can i get tc named table input value="75"

my input form

    <tr>
                            <th>Loan Amount</th>
                            <th>INTEREST RATE %</th>
    <tr>              
            <tbody>
<td><input disabled type="" name="tc" id="int_amount" class="formcontrol"value=""/></td>
<td><input  type="number" name="Interest" id="input2" onkeyup="calculate();"/ class="form-control" value=""/></td>

            </tr>
            </tbody>

javascript

var vatti = document.pricecal.Interest.value;
var Total = vatti -25;

    if(vatti = null)
    {

        document.getElementById("int_amount").innerHTML  = "Rs:"+" "+Total;

    }
[want out put like this][1]
1
  • 1
    What?!! Explain more please! Commented Oct 14, 2017 at 8:47

3 Answers 3

1

Hope this helps you.

function calculate(interest){
  var vatti = interest.value;
  if (vatti != '') {
    var Total = vatti - 25;
      document.getElementById("int_amount").value = Total;
  }else{
    document.getElementById("int_amount").value = '';
  }
}
<table>
    <tbody>
	<tr>
	    <td><input type="number" name="Interest" id="input2" onkeyup="calculate(this)" onchange="calculate(this)" class="form-control" value=""/></td>
	    <td><input type="" name="tc" id="int_amount" class="formcontrol" value=""/></td>
	</tr>
    </tbody>
</table>

Sign up to request clarification or add additional context in comments.

Comments

0

Set the .value of the <input> element, not the .innerHTML

document.getElementById("int_amount").value  = "Rs:"+" "+Total;

Comments

0

HTML:

<tbody>
  <tr>
    <td><input type="number" name="Interest" id="input2" class="form-control" value=""/></td>
    <td><input type="" name="tc" id="int_amount" class="formcontrol" value=""/></td>
  </tr>
</tbody>

Javascript:

document.getElementById('input2').onkeyup = function() {
    document.getElementById('int_amount').value = (this.value != '') ? 'Rs: ' + (parseInt(this.value)-25) : '';
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.