1

私は 4 つの chkboxes を持つフォームに取り組んでおり、1 つ以上の chkboxes を選択しています。フォームに特定の div を表示する 1 つの JavaScript 関数を呼び出しました。すべてが完璧に進んでいますが、問題は、一部の div で重複しているエントリがいくつかあり、重複したエントリを持つ div を選択すると、重複したエントリが 2 回表示されることです。そして、私はそれを望んでいません。そのため、フォーム上で重複するエントリは 1 回だけ表示されます。

助けてください。前もって感謝します....

これが私の試したコードです:

    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function fnchecked(blnchecked,divid)
    {
        if(blnchecked)
        {
            document.getElementById(divid).style.display= "";
        }
        else
        {
            document.getElementById(divid).style.display= "none";
        }
    }
    </script>
    </head>
    <body>

    <form name="shohide1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <div>
        <label>Technologies: </label></br>
        <input type="checkbox" name="technologies1" onClick="fnchecked(this.checked,'questions1');" /> Kingspan Solar</br>
        <input type="checkbox" name="technologies2" onClick="fnchecked(this.checked,'questions2');" /> Solar PVT</br>
        <input type="checkbox" name="technologies3" onClick="fnchecked(this.checked,'questions3');" /> Insulation</br>
        <input type="checkbox" name="technologies4" onClick="fnchecked(this.checked,'questions4');" /> Gas boiler</br>

        <div id="questions1" style="display:none;">
            <p>
              How many people live in the house ?
                  <select name="people">
                      <option value="">Click & Choose</option>
                      <option value="people1">1 to 3 (200 litre system)</option>
                      <option value="people2">3 to 4 (250 litre system)</option>
                      <option value="people3">4 to 6 (300 litre system)</option>
                      <option value="people4">6 to 9 (400 litre system)</option>
                  </select>
             </p>
             <p>
              What type of house do you live in?
                  <select name="house_type">
                      <option value="">Click & Choose</option>
                      <option value="house_type1">Bungalow</option>
                      <option value="house_type2">2 story</option>
                      <option value="house_type3">Dormer</option>
                      <option value="house_type4">3 or 4 story</option>
                      <option value="house_type5">Apartment</option>
                  </select>
             </p>
             <p>
              Is your house south facing?
                  <select name="house_face">
                      <option value="">Click & Choose</option>
                      <option value="house_face1">South</option>
                      <option value="house_face2">South east or South west</option>
                      <option value="house_face3">East or West</option>
                      <option value="house_face4">No</option>
                  </select>
             </p>
             <p>
              Was it built before 2006?
                  <select name="built">
                      <option value="">Click & Choose</option>
                      <option value="built1">Yes</option>
                      <option value="built2">No</option>
                  </select>
             </p>
        </div>
        <div id="questions2" style="display:none;">
            <p>
                  How many people live at the house ?
                      <select name="people">
                          <option value="">Click & Choose</option>
                          <option value="people1">1-2</option>
                          <option value="people2">3</option>
                          <option value="people3">4</option>
                          <option value="people4">4-6</option>
                          <option value="people4">6-8</option>
                      </select>
                 </p>
                 <p>
                  What type of house do you live in?
                      <select name="house_type">
                          <option value="">Click & Choose</option>
                          <option value="house_type1">Bungalow</option>
                          <option value="house_type2">2 story</option>
                          <option value="house_type3">Dormer</option>
                          <option value="house_type4">3 or 4 story</option>
                          <option value="house_type5">Apartment</option>
                      </select>
                 </p>
                 <p>
                  Is your house south facing?
                      <select name="house_face">
                          <option value="">Click & Choose</option>
                          <option value="house_face1">South</option>
                          <option value="house_face2">South east or South west</option>
                          <option value="house_face3">East or West</option>
                          <option value="house_face4">No</option>
                      </select>
                 </p>
                 <p>
                  Was it built before 2006?
                      <select name="built">
                          <option value="">Click & Choose</option>
                          <option value="built1">Yes</option>
                          <option value="built2">No</option>
                      </select>
                 </p>

        </div>
        <div id="questions3" style="display:none;">
          <p>
                What type of house do you live in?
                    <select name="house_type">
                        <option value="">Click & Choose</option>
                        <option value="house_type1">Bungalow</option>
                        <option value="house_type2">2 story</option>
                        <option value="house_type3">Dormer</option>
                        <option value="house_type4">3 or 4 story</option>
                        <option value="house_type5">Apartment</option>
                    </select>
               </p>
           <p>
            Is your house detached?
                <select name="detached">
                    <option value="">Click & Choose</option>
                    <option value="detached1">Detached</option>
                    <option value="detached2">Semi D</option>
                    <option value="detached3">Mid Terrace</option>
                    <option value="detached4">Apartment</option>
                </select>
           </p>
           <p>
            Was it built before 2006?
                <select name="built">
                    <option value="">Click & Choose</option>
                    <option value="built1">Yes</option>
                    <option value="built2">No</option>
                </select>
           </p>
        </div>
        <div id="questions4" style="display:none;">
        <p>
          How many bedrooms are in the house?
              <select name="bedroom">
                  <option value="">Click & Choose</option>
                  <option value="bedroom1">1-2</option>
                  <option value="bedroom2">2-3</option>
                  <option value="bedroom3">3-4</option>
                  <option value="bedroom4">4-5</option>
                  <option value="bedroom5">5-8</option>
              </select>
         </p>
         <p>
            What type of house do you live in?
                <select name="house_type">
                    <option value="">Click & Choose</option>
                    <option value="house_type1">Bungalow</option>
                    <option value="house_type2">2 story</option>
                    <option value="house_type3">Dormer</option>
                    <option value="house_type4">3 or 4 story</option>
                    <option value="house_type5">Apartment</option>
                </select>
         </p>
         <p>
          Was it built before 2006?
              <select name="built">
                  <option value="">Click & Choose</option>
                  <option value="built1">Yes</option>
                  <option value="built2">No</option>
              </select>
         </p>
        </div>
    </div>


    </body>
    </html> 
4

1 に答える 1