Can we give two values ​​in the input type of the button?

I have to specify two values ​​in the checkbox, since by these two values ​​the checkbox should be checked.

Can an if condition be used? or something else? I can't think of any good idea.

   <div class="Checkbox" style="width: 40px; height: 35px; margin-top: 3px;">
     <input type="checkbox" name="boxselector"  id="ROICheckBox"  onclick ="toggleCheckboxes(this);"   value="ROI" />
    <label for="ROICheckBox"  style="height: 10px; padding-bottom: 18px;" ></label>
   </div>

      

Now I have another Pixel value which should use the same checkbox as the ROI . How can i do this?

$("[name=boxselector]").click(function(
                      myPixelSetSel = undefined;
                       mySel = new Box2();
                       if (this.value === "ROI"){
                           mySel.isROI = true;
                       }
                       else if (this.value === "Layer"){
                           mySel.isLayer = true;
                       }
                       else if (this.value === "Metrics"){
                           mySel.isMetrics = true;
                          myPixelSetSel = 1;
//                           mySel = undefined;
                       }
                        else if (this.value === "MeasBox"){
                           mySel.isMeasBox = true;
                       }
                       else if(this.value === "Pixel"){
                         myPixelSetSel = 1;
                         mySel = undefined;
                    }

                } else {
                    sel = {};
                    mySel = undefined;
                    myPixelSetSel = undefined;
                }     
        });
       });

      

+3


source to share


1 answer


Why don't you have an array of these two values ​​if the first one is checked and let's suppose it is presented for example: Look here: http://jsfiddle.net/csdtesting/vcfvmLsy/



$('form').submit(function() {
  var arr = [];
  var chkel = $('input[name="boxselector"]');

  var valueToAdd = "Pixel";
  if ($(chkel).is(':checked')) {
    if ($(chkel).val() == "ROI")
      arr.push($(chkel).val());
    arr.push(valueToAdd);
  }
  console.log(arr);
  alert(arr[0]);
  alert(arr[1]);
  // Prevent actual submit for demo purposes:
  return false;
});
      

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="Checkbox" style="width: 40px; height: 35px; margin-top: 3px;">
  <input type="checkbox" name="boxselector" id="ROICheckBox" onclick="toggleCheckboxes(this);" value="ROI" checked="checked" />
  <label for="ROICheckBox" style="height: 10px; padding-bottom: 18px;"></label>
</div>
<form>
  <input id='my_match' type='hidden' name='my_match[]' />
  <button>Submit</button>
</form>
      

Run codeHide result


0


source







All Articles