I'm attempting to create a way for users to select a payment method (Debit, Credit, or PayPal). Depending on what value they select, I would like to bring up a new menu for payment info (card #, etc.). How would I go about doing this?

Here is the code:

Payment Method
<select name="Payment" id="Payment">
<option>Debit</option>
<option>Credit</option>
<option>PayPal</option>
</select>
</form>
有帮助吗?

解决方案

Here's a FIDDLE that'll get you started.

JS

$('#payment').change(function(){
              var selection = $('#payment').val();
              $('.putmehere img').hide();
              if(  selection == 'd')
                   {
                    $('#debit').show();
                    }
              if(  selection == 'c')
                   {
                    $('#credit').show();
                    }
              if( selection == 'p')
                   {
                    $('#paypal').show();
                    }

});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top