Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 2个按钮的条件_Javascript_Php_Jquery - Fatal编程技术网

Javascript 2个按钮的条件

Javascript 2个按钮的条件,javascript,php,jquery,Javascript,Php,Jquery,我想创建一个条件,如果用户选择单选按钮a,按钮将是这个 <input type="button" disabled="disabled" name="next" value="Proceed to Payment" onclick="window.location='shipping.php#openModal'"/> 但当用户选择单选按钮B时,该按钮将自动关闭 <input type="submit" disabled="disabled" name="order" val

我想创建一个条件,如果用户选择单选按钮a,按钮将是这个

<input type="button" disabled="disabled" name="next" value="Proceed to Payment" onclick="window.location='shipping.php#openModal'"/>
但当用户选择单选按钮B时,该按钮将自动关闭

<input type="submit" disabled="disabled" name="order" value="Proceed to Checkout"/>

我该怎么做?谢谢

您可以执行以下操作:

为每个按钮分配一个id,以便以后可以像$'id'一样选择它们,并为它们设置一个样式规则,display:none。由于此规则,当您加载页面时,它们都将不可见

<input id="buttonA" style="display: none" type="button" disabled="disabled" 
       name="next" value="Proceed to Payment" 
       onclick="window.location='shipping.php#openModal'"/>
将两个按钮放置在id为的1个div中 定义CSS类:。不可见{显示:无} 将不可见类添加到按钮,该按钮在开始时不可见 为radiobutton的更改事件创建事件处理程序 在事件处理程序中,通过步骤1中div的所有按钮子级切换不可见类,并使用其id查找它
我不知道如何使用javascript,我只是个新手@OhGodWhy做一些尝试,当您的代码有问题时,请告诉我们。您是否要求仅使用一个按钮来实现这一点?
<input id="buttonB" style="display: none" type="submit" disabled="disabled" 
       name="order" value="Proceed to Checkout"/>
function()
{
    if($('#radioButtonAId').checked())
    {
        $('#buttonA').show();
    }

    if($('#radioButtonBId').checked())
    {
        if($('#buttonB').show();
    }
} 
var R1 = document.getElementById('rb1');
var R2 = document.getElementById('rb2');

R1.onchange = function() {
    if(this.checked) {
        document.getElementById('buttonA').style.display = 'block';
        document.getElementById('buttonB').style.display = 'none';
    }
    else
    {
        document.getElementById('buttonA').style.display = 'none';
        document.getElementById('buttonB').style.display = 'block';
    }
}


R2.onchange = function() {
    if(this.checked) {
        document.getElementById('buttonA').style.display = 'none';
        document.getElementById('buttonB').style.display = 'block';
    }
    else
    {
        document.getElementById('buttonA').style.display = 'block';
        document.getElementById('buttonB').style.display = 'none';
    }
}