1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

checkboxes show undefined value

Discussion in 'JavaScript' started by gilgalbiblewheel, Feb 2, 2018.

  1. #1
    For some reason this isn't working. Both
    checked=true
    and
    checked==true
    don't work.
    
    //twotexts.js
    function strongsCheck(){
    var KeyWord = "&keyword=";
    var chkStrongsBox = document.getElementsByClassName("checkbox-inline");
    for(i=0;i<chkStrongsBox.length;i++){
    if(chkStrongsBox[i].checked=true){
    if(i<(chkStrongsBox.length-1)){
    KeyWord += +chkStrongsBox[i].value+"|";
    }else{
    KeyWord += +chkStrongsBox[i].value;
    }
    }
    }
    alert(KeyWord);
    }
    Code (markup):
    <div id="strongs_list">
    <label class="checkbox-inline-all" style="display: block;"><input id="id_all" onclick="if(this.checked){highlightThemAll(); highlightThem()}else{unhighlightThemAll(); unhighlightThem()};" style="border: 1px solid #FFFFFF;" value="all" type="checkbox">all Strongs' in Common</label><br>
    <label class="checkbox-inline" style="width: 80px; height: 40px; display: block; font-weight: bold; color: red" title="
    results:
    (' of their |fathers|,', ' unto your |fathers|;', ' unto their |fathers|:', ' of their |fathers|,', ' which their |fathers|', ' <em>themselves</em> more than their |fathers|,', ' their |fathers|,', ' therein, as their |fathers|')
    
    occuring 8 times as:
    (''ab', ''ab', ''ab', ''ab', ''ab', ''ab', ''ab', ''ab') - original language:('אָב', 'אָב', 'אָב', 'אָב', 'אָב', 'אָב', 'אָב', 'אָב') - description: ('a root', 'a root', 'a root', 'a root', 'a root', 'a root', 'a root', 'a root')
    
    related to:
    ()
    also look at:
    ">
    <input id="id_0" class="class_strongs" value="H1" onclick="strongsCheck(); if(this.checked){highlightThem1(); highlightThem2();}else{unhighlightThem();};" style="border: 1px solid #FFFFFF;" type="checkbox">[H1]</label><br>
    <label class="checkbox-inline" style="width: 80px; height: 40px; display: block; font-weight: bold; color: red" title="
    results:
    
    
    occuring times as:
    - original language: - description:
    
    related to:
    ()
    also look at:
    ">
    <input id="id_0" class="class_strongs" value="H4519" onclick="strongsCheck(); if(this.checked){highlightThem1(); highlightThem2();}else{unhighlightThem();};" style="border: 1px solid #FFFFFF;" type="checkbox">[H4519]</label><br>
    <label class="checkbox-inline" style="width: 80px; height: 40px; display: block; font-weight: bold; color: red" title="
    results:
    
    
    occuring times as:
    - original language: - description:
    
    related to:
    ()
    also look at:
    ">
    <input id="id_0" class="class_strongs" value="H27" onclick="strongsCheck(); if(this.checked){highlightThem1(); highlightThem2();}else{unhighlightThem();};" style="border: 1px solid #FFFFFF;" type="checkbox">[H27]</label><br>
    <label class="checkbox-inline" style="width: 80px; height: 40px; display: block; font-weight: bold; color: blue" title="
    results:
    (' |after|', ' |*|', ' |after|', ' |*|', ' |after|', ' |*|')
    
    occuring 6 times as:
    (''achar', ''achar', ''achar', ''achar', ''achar', ''achar') - original language:('אַחַר', 'אַחַר', 'אַחַר', 'אַחַר', 'אַחַר', 'אַחַר') - description: ('from אָחַר (H309)', 'from אָחַר (H309)', 'from אָחַר (H309)', 'from אָחַר (H309)', 'from אָחַר (H309)', 'from אָחַר (H309)')
    
    related to:
    H309('achar)
    also look at:
    ">
    <input id="id_1" class="class_strongs" value="H310" onclick="strongsCheck(); if(this.checked){highlightThem1(); highlightThem2();}else{unhighlightThem();};" style="border: 1px solid #FFFFFF;" type="checkbox">[H310]</label><br>
    <label class="checkbox-inline" style="width: 80px; height: 40px; display: block; font-weight: bold; color: blue" title="
    results:
    
    
    occuring times as:
    'achar - original language: - description:
    
    related to:
    ()
    also look at:
    ">
    </div>
    PHP:

     
    gilgalbiblewheel, Feb 2, 2018 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #2
    = is assignment, that would be wrong... == compares, but 'checked' only really needs loosy true, so just "if (Element.checked) {" is all you need... BUT...

    Your array contains the labels, NOT the inputs. DOH!

    That said, with the inlined style, inlined scripting, outmoded use of onevent, bizzaroland title="" values, and presence of scripting that seems to be just there to do CSS' job... NONE of which really even belongs in your markup, lack of for attributes on your labels, failure to even close your labels -- you've got problems! Problems like more than half that code belonging on the scrapheap.

    Of course if that was a proper FIELDSET instead of a DIV that would be your selector isolation letting you axe 90%+ of your classes altogether!
     
    deathshadow, Feb 2, 2018 IP