第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

選擇其他單選按鈕時(shí)隱藏 DIV

選擇其他單選按鈕時(shí)隱藏 DIV

慕碼人2483693 2024-01-03 14:38:36
請(qǐng)建議如何解決此問題:OptionA 單選按鈕顯示包含多個(gè)復(fù)選框的 DIV 塊,但 OptionB 單選按鈕無法通過左側(cè)單選按鈕隱藏顯示的塊 function ShowHideDiv(chkPassport) {  var dvPassport = document.getElementById("dvPassport");  dvPassport.style.display = chkPassport.checked ? "block" : "none";}function ShowHideDivl(chkPassport) {  var dvPassport = document.getElementById("dvPassport");  dvPassport.style.display = chkPassport.checked ? "block" : "none";}function getFeaturePrice() {}function calculateTotal() {}function hideTotal() {}<body onload='hideTotal()'>  <div id="wrap">    <form action="" id="softwareform" onsubmit="return false;">      <div>        <div class="cont_order">          <fieldset>            <label class='radiolabel'><input type="radio" name="selectedsoftware" onclick="calculateTotal();ShowHideDiv(this)" />Software A </label>            <label class='radiolabel'><input type="radio" name="selectedsoftware" onclick="calculateTotal();ShowHideDivl(this)" /> software B</label>            <div class='row'>              <div id="dvPassport" style="display: none">                <label class='inlinelabel'><input type="checkbox" name="selectedfeature" onclick="calculateTotal()" />Video                </label> </div>              <div id="dvPassportl" style="display:none">                <label class='inlinelabel'><input type="checkbox" name="selectedfeature" onclick="calculateTotal()" />Video</label>              </div>            </div>          </fieldset>        </div>        <div id="total">        </div>      </div>    </form>  </div>  <script src="script.js"></script></body>
查看完整描述

1 回答

?
Helenr

TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超4個(gè)贊

在您的代碼中,當(dāng)您這樣做時(shí)ShowHideDiv(this),您始終會(huì)傳遞當(dāng)前選定的單選按鈕。因此,為了查看選擇了哪一個(gè),您可以執(zhí)行以下操作:


  function ShowHideDiv(chkPassport) {

    var dvPassport = document.getElementById("dvPassport");

    dvPassport.style.display =

      chkPassport.value === "Round1" ? "block" : "none";

  }

你也有一個(gè)錯(cuò)字,ShowHideDivl()而不是ShowHideDiv()。

var featuresmonth = new Array();

featuresmonth["Round1"] = 300;

featuresmonth["Round2"] = 300;

featuresmonth["Round3"] = 300;

featuresmonth["Round4"] = 525;

featuresmonth["Round5"] = 2000;

featuresmonth["Round6"] = 2000;


function ShowHideDiv(chkPassport) {

  var dvPassport = document.getElementById("dvPassport");

  dvPassport.style.display =

    chkPassport.value === "Round1" ? "block" : "none";

}


function getFeaturePrice() {

  var getFeaturePrice = 0;

  var theForm = document.forms["softwareform"];

  var selectedFeature = theForm.elements["selectedfeature"];

  for (var i = 0; i < selectedFeature.length; i++) {

    if (selectedFeature[i].checked == true) {

      getFeaturePrice += featuresmonth[selectedFeature[i].value];

    }

  }

  return getFeaturePrice;

}


function calculateTotal() {

  var softwarePrice = getFeaturePrice();

  var formatter = new Intl.NumberFormat();

  `enter code here`;

  var divobj = document.getElementById("total");

  divobj.style.display = "block";

  divobj.innerHTML = "Total = " + formatter.format(softwarePrice);

}


function hideTotal() {

  var divobj = document.getElementById("total");

  divobj.style.display = "none";

}

<body onload="hideTotal()">

  <div id="wrap">

    <form action="" id="softwareform" onsubmit="return false;">

      <div>

        <div class="cont_order">

          <fieldset>

            <label class="radiolabel"><input

                  type="radio"

                  name="selectedsoftware"

                  value="Round1"

                  onclick="calculateTotal();ShowHideDiv(this)"

                />Software A

              </label>

            <label class="radiolabel"><input

                  type="radio"

                  name="selectedsoftware"

                  value="Round2"

                  onclick="calculateTotal();ShowHideDiv(this)"

                />

                software B</label

              >

              <div class="row">

                <div class="column">

                  <div class="blue-column">

                    <div id="dvPassport" style="display: none;">

                      <label class="inlinelabel"

                        ><input

                          type="checkbox"

                          name="selectedfeature"

                          value="Round3"

                          onclick="calculateTotal()"

                        />Video

                      </label>

        </div>

      </div>

  </div>

  <div class="column">

    <div class="green-column">

      <div id="dvPassportl" style="display: none;">

        <label class="inlinelabel"><input

                          type="checkbox"

                          name="selectedfeature"

                          value="Round4"

                          onclick="calculateTotal()"

                        />Video</label

                      >

                    </div>

                  </div>

                </div>

              </div>

              <div class="row"><div class="column"></div></div>

            </fieldset>

          </div>

          <div id="total"></div>

        </div>

      </form>

    </div>

    <script type="text/javascript">

      var featuresmonth = new Array();

      featuresmonth["Round1"] = 300;

      featuresmonth["Round2"] = 300;

      featuresmonth["Round3"] = 300;

      featuresmonth["Round4"] = 525;

      featuresmonth["Round5"] = 2000;

      featuresmonth["Round6"] = 2000;


      function ShowHideDiv(chkPassport) {

        var dvPassport = document.getElementById("dvPassport");

        dvPassport.style.display =

          chkPassport.value === "Round2" ? "block" : "none";

      }


      function getFeaturePrice() {

        var getFeaturePrice = 0;

        var theForm = document.forms["softwareform"];

        var selectedFeature = theForm.elements["selectedfeature"];

        for (var i = 0; i < selectedFeature.length; i++) {

          if (selectedFeature[i].checked == true) {

            getFeaturePrice += featuresmonth[selectedFeature[i].value];

          }

        }

        return getFeaturePrice;

      }

      function calculateTotal() {

        var softwarePrice = getFeaturePrice();

        var formatter = new Intl.NumberFormat();

        `enter code here`;

        var divobj = document.getElementById("total");

        divobj.style.display = "block";

        divobj.innerHTML = "Total = " + formatter.format(softwarePrice);

      }

      function hideTotal() {

        var divobj = document.getElementById("total");

        divobj.style.display = "none";

      }

    </script>

  </body>


查看完整回答
反對(duì) 回復(fù) 2024-01-03
  • 1 回答
  • 0 關(guān)注
  • 136 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)