Dave Bergschneider Dave Bergschneider - 7 months ago 30
AngularJS Question

Troubleshooting jQuery input value

I've been troubleshooting a form that allows for users to select an amount or select other amount. The other amount when click changes the amount to $5. I'm trying to get get it so that when the user changes the amount from 5 that it changes the amt = to user input.

The bit of script that changes it

function setDonrAmount(id){
var amt = id.substring(10);
if( amt == 'Other' ){ amt = 5}
var others = id.substring(0,10);

For reference here's the actual form. Help would be greatly appreciated. https://secure.pva.org/site/c.ajIRK9NJLcJ2E/b.9381225/k.8668/FY2016_March_Congressional/apps/ka/sd/donorcustom.asp


I've made a few updates to setDonrAmount() to handle custom donations.

$("#donrAmountInput").on("input", function() {

function setDonrAmount(id) {
  var amt;
  $('#donrAmountButtons .active').removeClass('active');

  if (id == "Other") {
    amt = $("#donrAmountInput").val();

    if ($("#donrAmountInput").val().length < 2)
      amt = amt > 5 ? amt : 5;

    $('#otherAmount button').addClass('active');
  else {
    amt = id.substring(10);
    $('#donrAmount' + amt).addClass('active');