Page 1 of 1

Drop down to radio button

Posted: Tue May 09, 2017 3:09 pm
by nicklas
I want to get the following to radio buttons instead of drop down.
I'm not sure how to do it. I would appreciate if someone could help me out :)

Code: Select all

<h2><?php echo $text_title; ?></h2>
<p><?php echo $text_description; ?></p>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
    <?php if ($type === 'SELECT'): ?>
        <p>
            <label for="factoring-menu"><?php echo $text_select_payment_method; ?></label>
            <select name="factoring-menu" id="factoring-menu" class="required-entry">
                <option selected value="FINANCING"><?php echo $text_financing_invoice; ?></option>
                <option value="CREDITACCOUNT"><?php echo $text_part_payment; ?></option>
            </select>
        </p>
    <?php endif; ?>
    <label for="social-security-number"><?php echo $text_social_security_number; ?></label>
    <input type="text" name="social-security-number" id="social-security-number" value="" autocomplete="off">
</form>
<div class="buttons">
    <div class="right">
        <input type="button" value="<?php echo $button_confirm; ?>" id="button-confirm" class="button"/>
    </div>
</div>
<script type="text/javascript">
    <!--
    $('#button-confirm').bind('click', function () {
		$(this).prop('disabled', true);
        $.ajax({
            url: '<?php echo html_entity_decode($action, ENT_QUOTES, 'UTF-8'); ?>',
            type: 'POST',
            cache: false,
            async: true,
            dataType: 'json',
            data: {
                'social-security-number': $('#social-security-number').val()
            },
			error:function(){
				$('#button-confirm').prop('disabled',false);
			},
            success: function (response) {
				$('#button-confirm').prop('disabled',false);
				if (response.status !== 'ok') {
                    if ($('#payex-error').is('*')) {
                        $('#payex-error').html(response.message);
                    } else {
                        $('<div id="payex-error" class="warning">' + response.message + '</div>').insertBefore('#form');
                    }
                    return false;
                }

                $(this).attr('disabled', 'disabled');
                $('#payex-error').remove();
                $('#form').get(0).setAttribute('action', response.redirect);
                setTimeout(function() {
                    $('#form').submit();
                }, 1000);
            }
        });
    });
    //-->
</script>

Re: Drop down to radio button

Posted: Tue May 09, 2017 4:04 pm
by kestas
Try this:

Code: Select all

<h2><?php echo $text_title; ?></h2>
<p><?php echo $text_description; ?></p>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
    <?php if ($type === 'radio'): ?>
	
	        <p>
            <label for="factoring-menu"><?php echo $text_select_payment_method; ?></label>
            <input  type="radio" name="factoring-menu" id="factoring-menu" class="required-entry" value="FINANCING" checked="checked"/><?php echo $text_financing_invoice; ?><br /> 
            <input  type="radio" name="factoring-menu" id="factoring-menu" class="required-entry" value="CREDITACCOUNT"/><?php echo $text_part_payment; ?>            
           </p>
    <?php endif; ?>
    <label for="social-security-number"><?php echo $text_social_security_number; ?></label>
    <input type="text" name="social-security-number" id="social-security-number" value="" autocomplete="off">
</form>
<div class="buttons">
    <div class="right">
        <input type="button" value="<?php echo $button_confirm; ?>" id="button-confirm" class="button"/>
    </div>
</div>
<script type="text/javascript">
    <!--
    $('#button-confirm').bind('click', function () {
		$(this).prop('disabled', true);
        $.ajax({
            url: '<?php echo html_entity_decode($action, ENT_QUOTES, 'UTF-8'); ?>',
            type: 'POST',
            cache: false,
            async: true,
            dataType: 'json',
            data: {
                'social-security-number': $('#social-security-number').val()
            },
			error:function(){
				$('#button-confirm').prop('disabled',false);
			},
            success: function (response) {
				$('#button-confirm').prop('disabled',false);
				if (response.status !== 'ok') {
                    if ($('#payex-error').is('*')) {
                        $('#payex-error').html(response.message);
                    } else {
                        $('<div id="payex-error" class="warning">' + response.message + '</div>').insertBefore('#form');
                    }
                    return false;
                }

                $(this).attr('disabled', 'disabled');
                $('#payex-error').remove();
                $('#form').get(0).setAttribute('action', response.redirect);
                setTimeout(function() {
                    $('#form').submit();
                }, 1000);
            }
        });
    });
    //-->
</script>

Re: Drop down to radio button

Posted: Sat May 13, 2017 6:31 pm
by nicklas
Thank you for your input but that didn't work :( Getting no options what so ever with that replacement code.

Re: Drop down to radio button

Posted: Sun May 14, 2017 3:54 pm
by kestas
I am sorry to hear that. Not having a full environment I just change the code without being able to run or debug it. If you need help please send me whole extension to me in PM. I'll check it.