简体   繁体   中英

Change script for radio buttons to regular buttons

So I have this script that I've been using that works nicely for an my purposes but it is built with radio buttons, and I've been asked to do another project with it, but my boss would like the buttons to now be regular, non-radio buttons.

Here is the code I've been using so far. It's a lot harder to change over radio-button code to regular button code than I thought! Any help would be very much appreciated, thanks!

<!DOCTYPE html>
<html>
<head>
<style>
#TFholder{
   background-image:url('truefalse.png');
   height:84px;
   width:576px;
}

button{
    height:84px; 
    width:280px; 
    color:white; 
    background-color:black;      
    margin-top:50px; 
    text-align:center; 
    line-height:10px;
    border:none;
    outline:none;}

button a{
    display:block;
    color:white;
    text-decoration:none;
    padding:20px 40px;}
</style>  

</head>
<body>

<script type="text/javascript">
function onCheck() {
if (document.getElementById('check1').checked) {
    document.getElementById('truebox').style.display = 'block';

    }
else document.getElementById('falsebox').style.display = 'block';

    }
</script>
<input type="radio" onclick="javascript:onCheck();" name="check" id="check1"><br> 
<input type="radio" onclick="javascript:onCheck();" name="check" id="check2"><br>
<div id="TFholder">
  <div id="truebox" style="display:none">
    <button type="button">CONTINUE!!!</a></div>
  </div>

  <div id="falsebox" style="display:none">
     <button type="button">SECOND BUTTON!!!</a></div>
  </div>
</div>

</body>
</html>

change HTML part to:

<input id="Button1" type="button" value="button" onclick="javascript:b1();"/><br />
<br />
<input id="Button2" type="button" value="button" onclick="javascript:b2();"/><br>

change Script part to:

<script type="text/javascript">
    function b1() {
        document.getElementById('truebox').style.display = 'block';
    }

    function b2() {
        document.getElementById('falsebox').style.display = 'block';
    }
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM