سؤال

there was a ton of different ways I seen to do this here on stackoverflow. However, I have tried them and can't get it to work.

Here is my current code.

http://jsfiddle.net/tech0925/C9Z8N/5/

Here is the javascript

function printcardCheck() {
       if (document.getElementById('print_card').checked) {
            document.getElementById('printvoucher-receiver').style.display = 'block';
            document.getElementById('printvoucher-receiver').style.padding = '10px 0 0 0';
            document.getElementById('print_cards').value = 'Add this value';
        } 
                   else document.getElementById('printvoucher-receiver').style.display = 'none';
}

See the fiddle link above.

هل كانت مفيدة؟

المحلول

http://jsfiddle.net/DerekL/Y4YNs/

I believe you want to do something like this. I will change it to native JS later.

<form>
    <label>
        <input type="radio" name="set1" value="A">A</label>
    <label>
        <input type="radio" name="set1" value="B">B</label>
    <label>
        <input type="radio" name="set1" value="C">C</label>
</form>
<div class="more" id="A">Some more options for A</div>
<div class="more" id="B">Some more options for B</div>
<div class="more" id="C">Some more options for C</div>
$("form input").change(function () {
    $(".more").removeClass("show")
        .filter("#" + $(this).val()).addClass("show");
});

نصائح أخرى

there should only be one tag that id is 'print_card',and you have two,so when getElementById('print_card') will return the first one, that is the radio

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top