I’ve added this to a site I’m working on but want to send the card type to be included when the form is submitted but don’t know how to update the input value when the card number is entered.
At the moment I’ve got a span class which shows the card image (done using the above example) and then the user has to select their payment method before the form will send. How do I change it so that the type is added to a hidden text field?
I’m a bit out of my depth here but as no one else has answered yet could you not check whether the span has a certain class added and then update the hidden input when you submit.
el is getting element(S) by class, not a single element by ID. Even if there is only ONE element with that class name, you need to index it to specify.
var el = $('.card');
...
if (el[0].hasClass('diner'))...
Also, I don’t see where the variable cardtype is being set…
$(cardType).val(creditCard)
If you mean the ID of ‘wp-cardType’ then that needs to be in quotes.