mercredi 6 septembre 2023

How to get Checked Values from Facets-CheckBox Group?

I'm using ORACLE APEX "Sample Maps" example on the "120 - Airports Faceted Search" page. I need to get the checked options from Facet "P120_STATE" (it's a checkbox group) and put this checked values in a Text Item called "CHECKED_STATES". I don't know how to get the checked values in this facet checkbox group. I need to get these checked values to use in another SQL command, for example:

select CITIES.ID as ID, CITIES.NAME as NAME, CITIES.STATE_CODE as STATE_CODE from CITIES CITIES where STATE_CODE IN ( :CHECKED_STATES )




mardi 5 septembre 2023

Excel VBA to auto-fill website checkboxes

My coding knowledge is quite limited, but I need some help from you guys.

The data in an excel table with 3 columns and 3 rows should be automatically marked into the 3x3 checkboxes on a web page. Chrome will be used.

I try to explain in the attached picture.Example Image

Can you help me with the vba code? Just filling in the boxes will suffice. There will be no click to save.

Thank you very much, best regards.

I tried to do it with Selenium but failed, I need working codes.




dimanche 3 septembre 2023

VBA Code to ensure that at least one checkbox is checked

I have a form (titled ReplacedParts) that is opened from original form (frmForm) and it uses checkboxes to track what parts were replaced on a rebuild. A total of 26 checkboxes. After you select the parts replaced, you press "Accept Changes" button. If no boxes are checked then i want there to be a msgbox pop up and i don't want the user to be able to continue until at least one box is checked. If at least one is checked, then i want ReplacedParts to hide (thus revealing the original form) and yes, i did include a last box for no parts replaced. Just need a little bit of code that would accomplish this.

I tried a few different ideas i found online but nothing has worked so far.




samedi 2 septembre 2023

Disable "Ship to a different address?" enabled by default in WooCommerce checkout

I'm using a template for my website, and the default value of "shipping to another address" is set to one. It causes opening a long form.

I have read there's no way to change it by CSS codes, but the information may not be up-to-date. So please check the picture and code, and if there's any way to address the issue, please let me know.

Content Management System: WordPress

screenshot of error

<input id="ship-to-different-address-checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" checked="checked" type="checkbox" name="ship_to_different_address" value="1">

I read online there's no way to change it by CSS codes, but the information may not be up-to-date. So please check the picture and code, and if there's any way to address the issue, please let me know.




vendredi 1 septembre 2023

jQuery Checkbox checked Limitation

I have 6 checkboxes in a group of food sides. Any or all of the six can be checked.

I have another group of 6 checkboxes of sauces that only one can be checked. On a specific condition, the Egg Rolls checkbox is checked, I would like to permit 2 of the checkboxes to be checked.

I have a JSFiddle HERE that shows my current code, although it does not permit 2 checkboxes to be selected if the Egg Roll checkbox is checked. I have alerts that clearly show the value of the declared variable "num" to be 2 when the Egg Roll checkbox is checked, but the function to limit the number of allowed checkboxes does not change from 1 to 2.

The HTML:

<!-- // **** Sides Table **** -->
<div>
  <table>
    <caption>Choose Your Sides</caption>
    <tr>
      <td><input type="checkbox" value="Mac \'n Cheese" name="side1" id="side1" data-price="2.50" class="item"><label for="side1">Mac 'n Cheese</label></td>
      <td><input type="checkbox" value="Egg Roll" name="side2" id="side2" data-price="3.00" class="item"><label for="side2">Egg Roll</label></td>
    </tr>
    <tr>
      <td><input type="checkbox" value="Green Beans" name="side3" id="side3" data-price="2.50" class="item"><label for="side3">Green Beans</label></td>
      <td><input type="checkbox" value="Potato Salad" name="side4" id="side4" data-price="2.50" class="item"><label for="side4">Potato Salad</label></td>
    </tr>
    <tr>
      <td><input type="checkbox" value="Seven Bean Chili" name="side5" id="side5" data-price="2.50" class="item"><label for="side5">Seven Bean Chili</label></td>
      <td><input type="checkbox" value="Cole Slaw" name="side6" id="side6" data-price="1.50" class="item"><label for="side6">Cole Slaw</label></td>
    </tr>
  </table>
</div>
<!-- // **** Sauce Table **** -->
<div>
  <table>
    <caption>Choose Your Sauce</caption>
    <tr>
      <td><input type="checkbox" value="Cheerwine" name="sauce" id="checkbox1" class="sauce"><label for="checkbox1">Cheerwine</label></td>
      <td><input type="checkbox" value="Hummer" name="sauce" id="checkbox2" class="sauce"><label for="checkbox2">Hummer</label></td>
    </tr>
    <tr>
      <td><input type="checkbox" value="Moovelous" name="sauce" id="checkbox3" class="sauce"><label for="checkbox3">Moovelous</label></td>
      <td><input type="checkbox" value="Mercy Me" name="sauce" id="checkbox4" class="sauce"><label for="checkbox4">Mercy Me</label></td>
    </tr>
    <tr>
      <td><input type="checkbox" value="Pepper Jacked" name="sauce" id="checkbox5" class="sauce"><label for="checkbox5">Pepper Jacked</label></td>
      <td><input type="checkbox" value="9mm" name="sauce" id="checkbox6" class="sauce"><label for="checkbox6">9mm</label></td>
    </tr>
  </table>
</div>

And the javascript code:

var last;
var num="";
num=1;
$('input:checkbox[id="side2"]').change(function () {
if($('#side2').prop('checked')) {
      num=2;
      alert (num);
} else {
      num=1;
      alert (num);
}
})

$('input:checkbox[class="sauce"]').change(function () {
if (this.checked) {
        if ($('input[type="checkbox"]:checked').length > num) {
            $(last).prop('checked', false);
        }
        last = this;
    }
});



Checkbox / Submit Logic issues

I have created a GUI using tkinter for an application deployer for my job. Im having an issue with 2 of my check boxes. I believe for some reason the Logic for my "Submit" button is getting confused

Ill elaborate...

When only selecting "Kaseya(AzureAD)" check box, then my submit button, In my logs I get

2023-09-01 12:51:09,465 - INFO - Currently selected options: []
INFO:main:Currently selected options: []
2023-09-01 12:51:09,466 - INFO - No options were selected.
INFO:main:No options were selected.

When only selecting "Trend(AzureAD)" check box, then my submit button, In my logs I get

2023-09-01 12:53:04,686 - INFO - Currently selected options: ['AzureAD']
INFO:main:Currently selected options: ['AzureAD']
2023-09-01 12:53:04,687 - INFO - Kaseya checkbox value for AzureAD: 0
INFO:main:Kaseya checkbox value for AzureAD: 0
2023-09-01 12:53:04,687 - INFO - Trend checkbox value for AzureAD: 1
INFO:main:Trend checkbox value for AzureAD: 1
2023-09-01 12:53:04,687 - INFO - Attempting to install TrendMicro
INFO:main:Attempting to install TrendMicro
ERROR:trend:Not connected to a domain. Current domain AzureAD FROM INSTALL_TREND()

The "Trend(AzureAD)" checkbox is working as expected, I have code to log the value of both active checkboxes when "Submit" button is pressed. Sense "Kaseya(AzureAD)" check box is not pressed it = 0.

When selecting both check boxes, then my submit button, In my logs I get

2023-09-01 12:54:32,387 - INFO - Currently selected options: ['AzureAD']
INFO:main:Currently selected options: ['AzureAD']
2023-09-01 12:54:32,388 - INFO - Kaseya checkbox value for AzureAD: 1
INFO:main:Kaseya checkbox value for AzureAD: 1
2023-09-01 12:54:32,389 - INFO - Trend checkbox value for AzureAD: 1
INFO:main:Trend checkbox value for AzureAD: 1
2023-09-01 12:54:32,389 - INFO - Attempting to install TrendMicro
INFO:main:Attempting to install TrendMicro
ERROR:trend:Not connected to a domain. Current domain AzureAD FROM INSTALL_TREND()
2023-09-01 12:54:32,390 - INFO - Attempting to install Kaseya
INFO:main:Attempting to install Kaseya
ERROR:kaseya:Not connected to a domain. Current domain AzureAD FROM INSTALL_KASEYA()

This is functioning as expected as well,

What doesn't make sense is why when I only select "Kaseya(AzureAD)" it comes back with no value in the check box and doesn't work but if "trend(AzureAD)" check box is selected as well, it works as expected.

Also don't be concerned with the ERROR, (AzureAD) is not a compatible domain for my install function. Its for Testing purposes and is working properly.

Below is my "Submit" button logic

def submit():
    global browser_checkboxes, kaseya_checkboxes, trend_checkboxes
    all_checkboxes = {**browser_checkboxes, **kaseya_checkboxes, **trend_checkboxes}
    selected_options = [option for option, var in all_checkboxes.items() if var.get() == 1]  

      # This line will log or print the selected options for debugging.
    logger.info(f"Currently selected options: {selected_options}")

    # checks if any Browser or Program has been selected to intall  
    if not selected_options:
        logger.info("No options were selected.")
        label.config(text="You have not selected any browsers or programs to install. Please select at least 1.")
        return
        
    # Check which Browsers to install and invoke the respective functions
    if "Chrome" in selected_options:
        logger.info("Attempting to install Chrome")
        install_chrome()
    if "Firefox" in selected_options:
        logger.info("Attempting to install Firefox")
        install_firefox()
        
    # Debugging logs to understand the values
    kaseya_selected = kaseya_checkboxes.get(domain_name).get()
    trend_selected = trend_checkboxes.get(domain_name).get()

    logger.info(f"Kaseya checkbox value for {domain_name}: {kaseya_selected}")
    logger.info(f"Trend checkbox value for {domain_name}: {trend_selected}")
    
    # Checks if Trend has been selected then calls the install_trend() from trend.py
    if trend_selected == 1:
        logger.info("Attempting to install TrendMicro")
        install_trend()

    # Checks if Kaseya has been selected then calls the install_kaseya from kaseya.py 
    if kaseya_selected == 1:
        logger.info("Attempting to install Kaseya")
        install_kaseya()



jQuery checkbox function not working with show/hide

I have 2 divs with group of checkboxes that conditionally permit 1 or 2 boxes to be selected. The functions work well when both div groups are not hidden by default. I created a Jsfiddle HERE to demonstrate the issue.

If a client chooses an Egg Roll, they are permitted an additional sauce. My intent is to allow 2 selections only if an eggroll is selected. Currently, if I show or hide a div before selecting a sauce, the function that permits 2 selections breaks.

Any help to make the code work on one div only, or on both divs when they are shown or hidden, would be appreciated.

var last1;
var last2;

$('input:checkbox[id="side2"]').change(function() {
  if ($('#side2').prop('checked')) {
    $("#sauce1Container").hide();
    $("#sauce2Container").show();
    //      $('.sauce1').prop("checked", false);
  } // else {
  //    $("#sauce1Container").show();
  //    $("#sauce2Container").hide();
  //  $('.sauce2').prop("checked", false);
  //}
})


$('input:checkbox[class="sauce1"]').change(function() {
  if (this.checked) {
    $('.sauce2').prop("checked", false);
    if ($('input[type="checkbox"]:checked').length > 1) {
      $(last1).prop('checked', false);
    }
    last1 = this;
  }
});

$('input:checkbox[class="sauce2"]').change(function() {
  if (this.checked) {
    $('.sauce1').prop("checked", false);
    if ($('input:checkbox[type="checkbox"]:checked').length > 2) {
      $(last2).prop('checked', false);
    }
    last2 = this;
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="sidesContainer form-group mb-4 w-100" id="sidesContainer">
  <table class="sides">
    <caption>Add Your Sides</caption>
    <tr>
      <td><input type="checkbox" value="Mac \'n Cheese" name="side1" id="side1" data-price="2.50" class="item"><label for="side1">Mac \'n Cheese</label></td>
      <td><input type="checkbox" value="Egg Roll" name="side2" id="side2" data-price="3.00" class="item"><label for="side2">Egg Roll</label></td>
    </tr>
    <tr>
      <td><input type="checkbox" value="Green Beans" name="side3" id="side3" data-price="2.50" class="item"><label for="side3">Green Beans</label></td>
      <td><input type="checkbox" value="Potato Salad" name="side4" id="side4" data-price="2.50" class="item"><label for="side4">Potato Salad</label></td>
    </tr>
    <tr>
      <td><input type="checkbox" value="Seven Bean Chili" name="side5" id="side5" data-price="2.50" class="item"><label for="side5">Seven Bean Chili</label></td>
      <td><input type="checkbox" value="Cole Slaw" name="side6" id="side6" data-price="1.50" class="item"><label for="side6">Cole Slaw</label></td>
    </tr>
  </table>
</div>
// **** Sauce 1 Table ****
<div class="sauce1Container form-group mb-4 w-100" id="sauce1Container">
  <table class="sauces">
    <caption>Choose 1 Sauce</caption>
    <tr>
      <td><input type="checkbox" value="Cheerwine" name="sauce" id="checkbox1" class="sauce1"><label for="checkbox1">Cheerwine</label></td>
      <td><input type="checkbox" value="Hummer" name="sauce" id="checkbox2" class="sauce1"><label for="checkbox2">Hummer</label></td>
    </tr>
    <tr>
      <td><input type="checkbox" value="Moovelous" name="sauce" id="checkbox3" class="sauce1"><label for="checkbox3">Moovelous</label></td>
      <td><input type="checkbox" value="Mercy Me" name="sauce" id="checkbox4" class="sauce1"><label for="checkbox4">Mercy Me</label></td>
    </tr>
    <tr>
      <td><input type="checkbox" value="Pepper Jacked" name="sauce" id="checkbox5" class="sauce1"><label for="checkbox5">Pepper Jacked</label></td>
      <td><input type="checkbox" value="9mm" name="sauce" id="checkbox6" class="sauce1"><label for="checkbox6">9mm</label></td>
    </tr>
  </table>
</div>
// **** Sauce 2 Table ****
<div class="sauce2Container form-group mb-4 w-100" id="sauce2Container">
  <table class="sauces">
    <caption>Choose 2 Sauces</caption>
    <tr>
      <td><input type="checkbox" value="Cheerwine" name="sauce" id="checkbox7" class="sauce2"><label for="checkbox1">Cheerwine</label></td>
      <td><input type="checkbox" value="Hummer" name="sauce" id="checkbox8" class="sauce2"><label for="checkbox2">Hummer</label></td>
    </tr>
    <tr>
      <td><input type="checkbox" value="Moovelous" name="sauce" id="checkbox9" class="sauce2"><label for="checkbox3">Moovelous</label></td>
      <td><input type="checkbox" value="Mercy Me" name="sauce" id="checkbox10" class="sauce2"><label for="checkbox4">Mercy Me</label></td>
    </tr>
    <tr>
      <td><input type="checkbox" value="Pepper Jacked" name="sauce" id="checkbox11" class="sauce2"><label for="checkbox5">Pepper Jacked</label></td>
      <td><input type="checkbox" value="9mm" name="sauce" id="checkbox12" class="sauce2"><label for="checkbox6">9mm</label></td>
    </tr>
  </table>
</div>