Need help with code for displaying payment fields for WC gateway

I am looking to do something similar to this -
https://stackoverflow.com/questions/29958410/how-to-change-woocommerce-checkout-page-payment-mode-options

Here is what I have so far:

On selection from the dropdown, the payment fields should display in the .pay-fields div:

<div class="columns large-6 method-selector">

<?php if ( WC()->cart->needs_payment() ) : ?>
<ul class="wc_payment_methods payment_methods methods">

<?php
echo '<label for="">Payment Method</label><select name="payment_method">';
foreach ($available_gateways as $gateway) { ?>
<option value="payment_method_<?php echo esc_attr( $gateway->id ); ?>"><?php echo $gateway->get_title(); ?></option>

<?php }
echo '</select>';
?>

<?php endif; ?>

</div>

<div class="columns large-6 pay-fields">

<?php foreach ($available_gateways as $gateway) { 

if ( $gateway->has_fields() || $gateway->get_description() ) : ?>

<div class="payment_box" id="payment_method_<?php echo $gateway->id; ?>">
<?php if ( ! $gateway->chosen ) : ?>
<?php echo $gateway->payment_fields(); ?>
<?php endif; ?>
</div>

<?php endif; } ?>

</div>

</div>