unixmiah unixmiah - 1 year ago 95
Javascript Question

JQuery insert calculated value into a form text field

I have a form below

<form id="credit-card-submission-form-1" class="visual-form-builder vfb-form-1 " method="post" enctype="multipart/form-data">

and I have this following field within the

type="text" name="vfb-17" id="vfb-17" value="" class="vfb-text vfb-medium required " />

I want to take input value from this field below, lets say if
was entered from
field, I want to take the
and apply
to this field

type="text" name="vfb-15" id="vfb-15" value="" class="vfb-text vfb-medium required " />

This is what I have tried so far just to test out if I can access the field:

<script type="text/javascript">
jQuery(document).ready(function($) {
$('#vfb-17').val( $('#vfb-17').val() + 'My new text' )

I can't get this value/'My new text' even inserted into the field in the above JQuery.

Answer Source

try this :

  var vfbVal = $(this).val();
  var vfb15Val = (vfbVal*3.5)/100;
  $('#vfb-15').val(vfb15Val+'My new text');


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download