How do I make my array items display different? [duplicate]

Let’s say I have an inventory array:

    inventory = []

    inventory.push(newLog);
    text.innerText = " You have added " + newLog + " to your inventory!"
    await sleep(1500);
    text.innerText = " In your inventory you now have: " + inventory + ", ";

This example is chopping a log. When it adds to the inventory it shows “In your inventory you now have (whatever, whatever, log).

If I chop another log it shows “In your inventory you now have (whatever, whatever, log, log).

I want it to display as (Whatever, whatever, log(2)). How do I make this possible?

I have looked around to see ways to implement this, and I cannot find it. Maybe like an item stacking code may work?

Integrating Rails App using React framework with Azure

I’m trying to figure out the best course of action to integrate a Rails app with Azure cloud services.

I’m working on a team project where I’m leading the cloud side of things, using Azure. We are making a web app using Rails and utilizing the React library. We are also using Azure SQL for the DB. I’m wondering if anyone can help with figuring out the best course of action to integrate our app with Azure and hosing it on the cloud.

My goal is to have our project connect to the cloud so that I’ll be able to set up a testing environment so that someone can interact with our app without having the environment set up (someone like a stakeholder for example in another part of the country, etc).

So far, my services include a Static Web App, database, and App Service. I also have DevOps set up mirroring our main repo in GitLab. They are not all completely set up/connected.

I’m trying to figure this out using a static web app, but having some issues setting it up and connecting the API. I’ve been looking at a lot of resources and the Azure docs, but a lot of it has to do with starting things from the ground-up, whereas we have a lot of stuff built already. Does anyone have any steps, tips, or resources that will be helpful moving forward? I feel like I’ve just been going in circles.

I hope this question was clear enough. This is also a school project and we are trying to keep things free. We do have a small budget if necessary. Thanks in advance!

Disable all WooCommerce shipping methods, except Local Pickup, when custom checkbox is checked?

I am running into an issue with hiding shipping methods when a custom local pickup checkbox is selected during the shipping step in checkout.

Ideally, checking this custom checkbox would set the chosen shipping method to local pickup and disable/hide all other available methods. All available methods should consequently be available when unchecked.

Below is the code I currently have in place, and is somewhat functional in that it does hide and uncheck all other available methods except local pickup. However, the total at checkout still includes the shipping cost as if the other shipping method is still selected.

After reading up on this, it seems I need to incorporate ajax/php to accomplish this. Any help on this would be greatly appreciated!

<script type="text/javascript">
//the following code is responsible for custom checkout functions
window.onload = function(){
//Define Shipping Variables
const shipFirstName = document.querySelector('#shipping_first_name');
const shipLastName = document.querySelector('#shipping_last_name');
const shipPhone = document.querySelector('#shipping_phone');
const shipCompany = document.querySelector('#shipping_company');
const shipAddress = document.querySelector('#shipping_address_1');
const shipAddress2 = document.querySelector('#shipping_address_2');
const shipCity = document.querySelector('#shipping_city');
const shipState = document.querySelector('#shipping_state');
const shipStateOption = shipState.options[shipState.selectedIndex];
const shipZip = document.querySelector('#shipping_postcode');
const shipCountry = document.querySelector('#shipping_country');

//Define Shipping Field Input Container Variables
const shipFirstNameField = document.querySelector('#shipping_first_name_field');
const shipLastNameField = document.querySelector('#shipping_last_name_field');
const shipPhoneField = document.querySelector('#shipping_phone_field');
const shipCompanyField = document.querySelector('#shipping_company_field');
const shipAddressField = document.querySelector('#shipping_address_1_field');
const shipAddress2Field = document.querySelector('#shipping_address_2_field');
const shipCityField = document.querySelector('#shipping_city_field');
const shipStateField = document.querySelector('#shipping_state_field');
const shipStateContainer = document.querySelector('select2-shipping_state-container');
const shipZipField = document.querySelector('#shipping_postcode_field');
const shipCountryField = document.querySelector('#shipping_country_field');
const shipDeliveryField = document.querySelector('#e_deliverydate_0_field');

//Define Billing Variables
const billFirstName = document.querySelector('#billing_first_name');
const billLastName = document.querySelector('#billing_last_name');
const billPhone = document.querySelector('#billing_phone');
const billCompany = document.querySelector('#billing_company');
const billAddress = document.querySelector('#billing_address_1');
const billAddress2 = document.querySelector('#billing_address_2');
const billCity = document.querySelector('#billing_city');
const billState = document.querySelector('#billing_state');
const billStateOption = billState.options[billState.selectedIndex];
const billStateContainer = document.querySelector('#select2-billing_state-container');
const billZip = document.querySelector('#billing_postcode');

//Define Qualifying Field Inputs & Values
const pickUpBtn = document.querySelector('#pick-up-qualifier');
const copyBtn = document.querySelector('#copy_shipping_to_billing');

//Define Default Value of Local Pick Up as False
var localPickUp = false;
    
//Set Conditions Based on Selection of In-Store PickUp
function localPickUpSelection(){
    if (pickUpBtn.checked) {
        localPickUp = true;
        shipFirstNameField.style.display = "none";
        shipFirstNameField.classList.add("woocommerce-validated");
        shipLastNameField.style.display = "none";
        shipLastNameField.classList.add("woocommerce-validated");
        shipPhoneField.style.display = "none";
        shipPhoneField.classList.add("woocommerce-validated");
        shipCompanyField.style.display = "none";
        shipCompanyField.classList.add("woocommerce-validated");
        shipAddressField.style.display = "none";
        shipAddressField.classList.add("woocommerce-validated");
        shipAddress2Field.style.display = "none";
        shipAddress2Field.classList.add("woocommerce-validated");
        shipCityField.style.display = "none";
        shipCityField.classList.add("woocommerce-validated");
        shipStateField.style.display = "none";
        shipStateField.classList.add("woocommerce-validated");
        shipZipField.style.display = "none";
        shipZipField.classList.add("woocommerce-validated");
        shipCountryField.style.display = "none";
        shipCountryField.classList.add("woocommerce-validated");
        //shipDeliveryField.classList.add("rcb-custom-hide");

    } else{
        localPickUp = false;
        //shipDeliveryField.style.display = "block";
        shipFirstNameField.style.display = "block";
        shipFirstNameField.classList.remove("woocommerce-validated");
        shipLastNameField.style.display = "block";
        shipLastNameField.classList.remove("woocommerce-validated");
        shipPhoneField.style.display = "block";
        shipPhoneField.classList.remove("woocommerce-validated");
        shipCompanyField.style.display = "block";
        shipCompanyField.classList.remove("woocommerce-validated");
        shipAddressField.style.display = "block";
        shipAddressField.classList.remove("woocommerce-validated");
        shipAddress2Field.style.display = "block";
        shipAddress2Field.classList.remove("woocommerce-validated");
        shipCityField.style.display = "block";
        shipCityField.classList.remove("woocommerce-validated");
        shipStateField.style.display = "block";
        shipStateField.classList.remove("woocommerce-validated");
        shipZipField.style.display = "block";
        shipZipField.classList.remove("woocommerce-validated");
        shipCountryField.style.display = "block";
        shipCountryField.classList.remove("woocommerce-validated");
        //shipDeliveryField.classList.remove("rcb-custom-hide");
    }
};

//Filter Available Shipping Methods Based on In-Store Pick Up Selection
function deliveryFilter(){
    
    const shippingMethods = document.querySelectorAll("input[name='shipping_method[0]']");
    const alwaysVisibleInput = document.querySelector("input[id^='shipping_method_0_local_pickup']");
    const alwaysVisibleLabel = document.querySelector("label[for^='shipping_method_0_local_pickup']");
    var shippingMethodLabels = document.querySelectorAll("label[for^='shipping_method_0']");
    
    if (localPickUp === true){
        shippingMethods.forEach((item) => {
            item.classList.add("rcb-custom-hide");
            alwaysVisibleInput.classList.remove("rcb-custom-hide");
        });
        shippingMethodLabels.forEach((item) => {
            item.classList.add("rcb-custom-hide");
            alwaysVisibleLabel.classList.remove("rcb-custom-hide");
        });
        
        shippingMethods.checked = false;
        alwaysVisibleInput.checked = true;
        
        shipFirstName.value = billFirstName.value;
        shipLastName.value = billLastName.value;
        shipPhone.value = billPhone.value;
        shipCompany.value = billCompany.value;
        shipAddress.value = billAddress.value;
        shipAddress2.value = billAddress2.value;
        shipCity.value = billCity.value;
        shipState.value = billState.value;
        shipZip.value = billZip.value;
        
        console.log("Billing information has been copied to shipping inputs successfully.");
        
    }else {
        shippingMethods.forEach((item) => {
            item.classList.remove("rcb-custom-hide");
        });
        shippingMethodLabels.forEach((item) => {
            item.classList.remove("rcb-custom-hide");
        });
    };
};

//Copy Shipping Field Information to Billing Fields
copyBtn.addEventListener('change', function(){
    if (this.checked) {
        var shipState = document.querySelector('#shipping_state');
        var shipStateOption = shipState.options[shipState.selectedIndex];
        billStateContainer.textContent = shipStateOption.text;
        console.log(shipStateOption.text);
        billFirstName.value = shipFirstName.value;
        billLastName.value = shipLastName.value;
        billPhone.value = shipPhone.value;
        billCompany.value = shipCompany.value;
        billAddress.value = shipAddress.value;
        billAddress2.value = shipAddress2.value;
        billCity.value = shipCity.value;
        billState.value = shipState.value;
        billZip.value = shipZip.value;
    } 
});
    
//Define Checkout Form Variables
const finalCheckoutStep = document.querySelector('.wpmc-step-payment');
    
//Observe Class Change in Final Checkout Step & Filter Delivery Options
var ob = new MutationObserver(function() {
    deliveryFilter();
});
ob.observe(finalCheckoutStep, {
    attributes: true,
    attributeFilter: ["class"]
});
    
//Run localPickUpSelection Function on Page Load
window.onload = localPickUpSelection();
    
//Run localPickUpSelection Function When Checkbox Value Changes
pickUpBtn.addEventListener('change', localPickUpSelection);
    
};
</script>

I tried hiding/disabling shipping methods via javascript, which worked, however the cart total is still reflecting a shipping cost when Local Pickup is selected.

jquery Uncaught Error: Syntax error, unrecognized expression:

 //jQuery local variable
var type = $(this).data('tab');
$('#tab-' + type).show();


In my HTML I have a div with with an id of tab and erb code <%= p.pricing_type %> that is supposed to return an integer value:

<div class="tab-content" id="tab-<%= p.pricing_type %>" style="<%= 'display: none' if !p.basic? %>">
 <div class="card">
      <div class="card-content">
         <div class="media">
             <div class="media-content">
                <strong><%= p.title %></strong>
              </div>
              <div class="media-right">
                 <p class="title is-4">$<%= p.price %></p>
              </div>
                </div>
</div>
,

I am trying to target the div with a class of tab-content and id of tab-<%= p.pricing_type %> on the above code, the accessing that code it throws the following error:

jquery.min.js:2 Uncaught Error: Syntax error, unrecognized expression: #tab-<= key %>
    at oe.error (jquery.min.js:2:12961)

the metadata of a jupyter ipynb cell is not loaded when i use fs.readfile(filePath,’utf-8′) in extension.js

When I try to get the metadata of individual cells in ipynb file in vscode using javascript, the metadata is {}, the metadata of individual cells was not loaded, even when I opened a ipynb file in text editor.
Metadata image of a cell

I have tried opening the ipynb file directly via text editor, but still the metadata is empty.
Give me a solution to get the metadata loaded into it.

How to replace isolate() with another reactivity management function that serves the same purpose in R Shiny?

The below example code has 3 linked user input matrixes: the first, base_input, allows the user to make static inputs and the next 2 user input matrixes, var_1_input and var_2_input (collectively, “var_x_input”), are reactively fed the values from base_input and the slider input for time horizon, and allow the user to alter the time dimension in their respective left-most user input columns labeled “X”. The image below shows the data flows. How can I replace the one isolate() in this code with other reactivity-management code?

The problem I’m having is the isolate() conflicts with the js code for managing decimals. The js code ensures that a minimum of 2 decimal places are shown in the matrix input cells. When activating the js code (commented-out below), the reactivity flow between base_input and the var_x_input matrixes no longer works (meaning for example an input in base_input[1,1] needs to be instantly reflected in the upper right cell of var_1_input), although the decimals work perfectly. If I remove the isolate(), then another undesirable happens: changing a value in one cell in base_input resets both of the var_x_input matrixes instead of just the var_x_input matrix linked to base_input. The isolate() ensures that each var_x_input is indepenendently linked to its corresponding cell in base_input.

I’m trying to get all 3 features working: downstream reactivity between base_input and the var_x_input matrixes; formatting of specified user input cells with a minimum of 2 decimal places (per the js code); and changing the base_input cell for one var_x_input should reset only that var_x_input matrix and not all of the var_x_input matrixes.

enter image description here

Code:

library(shinyMatrix)
library(shiny)
library(shinyjs)

# js <- "
# $(document).on('shiny:bound', function(event) {
#   var $elem = $(event.target);
#   if($elem.hasClass('vue-input')) {
#     $elem.find('td').each(function() {
#       var $td = $(this);
#       var columnIndex = $td.index();
#       var $table = $td.closest('.vue-input');
#       var tableId = $table.attr('id');
#       var isVarInput = tableId.startsWith('var_') && tableId.endsWith('_input');
#       var text = $td.find('span').text();
#       var num = parseFloat(text);
# 
#       if (!isNaN(num)) {
#         if (isVarInput && columnIndex == 0) {
#           // Format with 0 decimal places for the first column of var_x_input
#           $td.find('span').html(num.toFixed(0));
#         } else {
#           // Use 2 decimal places for the second column of var_x_input and other cases
#           var decimalPlaces = (text.split('.')[1] || []).length;
#           var fixed = decimalPlaces < 2 ? 2 : decimalPlaces;
#           $td.find('span').html(num.toFixed(fixed));
#         }
#       }
#     });
#   }
# });
# 
# $(document).ready(function() {
#   $('body').on('focusout', '.vue-input table td input', function(e) {
#     var $td = $(this).parent();
#     var columnIndex = $td.index();
#     var $table = $td.closest('.vue-input');
#     var tableId = $table.attr('id');
#     var isVarInput = tableId.startsWith('var_') && tableId.endsWith('_input');
# 
#     var interval = setInterval(function() {
#       if ($td.children().is('span')) {
#         clearInterval(interval);
#         var $span = $td.find('span');
#         var text = $span.text();
#         var num = parseFloat(text);
# 
#         if (!isNaN(num)) {
#           if (isVarInput && columnIndex == 0) {
#             // Format with 0 decimal places for the first column of var_x_input
#             $span.html(num.toFixed(0));
#           } else {
#             // Use 2 decimal places for the second column of var_x_input and other cases
#             var decimalPlaces = (text.split('.')[1] || []).length;
#             var fixed = decimalPlaces < 2 ? 2 : decimalPlaces;
#             $span.html(num.toFixed(fixed));
#           }
#         }
#       }
#     }, 50);
#   });
# });
# "

matInputBase <- function(name) {
  matrixInput(name,
              value = matrix(rep(0.20,2),2, 1,dimnames = list(c("A","B"), NULL)),
              rows = list(extend = FALSE, names = TRUE),
              cols = list(extend = FALSE, names = FALSE, editableNames = FALSE),
              class = "numeric")
}

matInputVary <- function(name, x,y) {
  matrixInput(
    name,
    value = matrix(c(x, y), 1, 2, dimnames = list(NULL,c("X","Y"))),
    rows = list(extend = TRUE, names = FALSE),
    cols = list(extend = TRUE, delta = 0, names = TRUE, editableNames = FALSE),
    class = "numeric"
  )
}

ui <- fluidPage(
  useShinyjs(),
  # tags$head(tags$script(HTML(js))),
  sliderInput("periods","Time window (W):", min = 1, max = 120, value = 60),
  h5(strong("Variable (Y) over window (W):")),
  matInputBase("base_input"),
  uiOutput("Vectors")
)

server <- function(input, output, session) {
  prev_base_input <- reactiveValues(data = matrix(NA, nrow = 2, ncol = 1))

  observeEvent(input$base_input, {
    for (i in 1:2) {
      if (is.na(prev_base_input$data[i,1])||input$base_input[i,1]!=prev_base_input$data[i,1]){
        updateMatrixInput(
          session,
          paste0("var_", i, "_input"),
          value = matrix(c(input$periods,input$base_input[i,1]),1,2,dimnames=list(NULL,c("X","Y")))
        )
        prev_base_input$data[i, 1] <- input$base_input[i, 1]
      }
    }
  })
  
  output$Vectors <- renderUI({
    input$resetVectorBtn
    varNames <- c("A", "B")
    tagList(
      lapply(1:2, function(i) {
        list(
          h5(strong(paste("Adjust", varNames[i], "(Y) at time X:"))),
          matInputVary(paste0("var_", i, "_input"), input$periods, isolate(input$base_input[i,1]))
        )
      })
    )
  })
}

shinyApp(ui, server)

Kafka auth failed while implementing GSSAPI auth in Nodejs app

I’m currently looking to connect my nodejs app (using kafkajs package) with
a kerberised kafka cluster (GSSAPI enabled, openldap) but facing the
SASL_AUTHENTICATION_FAILED error when trying to authenticate with a SPNEGO
token.

Kafkajs library has no built in support for GSSAPI mechanism. I’m not sure
if it’s the right approach but I have come as far as getting a ticket from
the openldap server and creating a SPNEGO token (base64) from it but don’t
know what approach to take further.

I think encoding is the issue here but I’m a newbie at it and seeking out
guidance on how to approach this problem.

HTML close() does nothing

I’m attaching confirmation <dialog>s to any forms that need them with

const forms = document.querySelectorAll("form[data-confirm]");
forms.forEach((form) => {
    const confirm = document.createElement("dialog");
    const message = document.createElement("p");
    const cancel  = document.createElement("button");
    const accept  = document.createElement("button");
    message.innerText = form.dataset.confirm;
    cancel.innerText = form.dataset.cancel;
    accept.innerText = form.dataset.accept;
    confirm.appendChild(message);
    confirm.appendChild(cancel);
    confirm.appendChild(accept);
    form.appendChild(confirm);
    form.onsubmit = (event) => {
        event.preventDefault();
        confirm.showModal();
    }
    cancel.onclick = () => {
        console.log(confirm.close)
        confirm.close();
    }
    accept.onclick = () => {
        form.submit();
    }
});

This seems to work well, apart from the close() method, which does nothing and throws no error. Logging the function to the console shows

function close()
length: 0
name: "close"
<prototype>: function ()

in Firefox, while Edge & Chrome show

f close() { [native code] }

Changing the call to hide() as a test predictably results in

Uncaught TypeError: confirm.hide is not a function

Logging the dialog itself shows that we’re dealing with the right DOM object:

...

cancel.onclick = () => {
    console.log(confirm)
    confirm.close();
}
> <dialog open="">
...

​<prototype>: HTMLDialogElementPrototype { show: show(), showModal: showModal(), close: close(), … }

There are no other dialogs on the page. I seem to be the only one who’s run into this problem, which makes me think a facepalm moment is not far off. Can you deliver it?

Is there a way to retrieve information from an ESXi server using JavaScript?

I’m here because I need to retrieve information from an ESXi server with a web page.
The information I need are CPU, Memory and Storage, max and used.

I would like a way to read information from Vsphere or directly an ESXI. Or just some guidance (I’m new to both technologies).

I’ve try some way, ssh connection, js-vmware lib, the vmware API, but I don’t seems to find a way to make it work with JavaScript.

react js sending request in loop when an exception throw from backend

i have react js which intercepts response and check for jwt token expiry and issue refresh token

request interceptor..

customAxios.interceptors.request.use(async (config) => {
  const user = JSON.parse(localStorage.getItem('authUser'));
  console.log('request interceptor user ' + user);
  if (user?.productUserMO) {
    config.headers['X-TENANTID'] = `${user.productUserMO.customerId}`;
  }
  if (user && user.token) {
    config.headers["Authorization"] = `Bearer ${user.token}`;
  }
  return config;
});

response interceptor

customAxios.interceptors.response.use(
  undefined,
  error => {
    const errorConfig = error.config;
    const user = JSON.parse(localStorage.getItem('authUser'));
    console.log("url is" + errorConfig.url)
    if (user) {
      if (errorConfig.url !== Constants.LOGIN_URL) {
        if (error.response?.status === 401 && !errorConfig.retry) {
         
          errorConfig.retry = true;
          //get refresh token if token got expired else redirect to token expired page
          if (!refreshPromise) {
            const user = JSON.parse(localStorage.getItem('authUser'));
            UserService.refreshToken(user)
              .then(response => {  sot 
                localStorage.setItem('authUser', JSON.stringify(response.data));
                refreshPromise = response.data.refreshToken
                return customAxios(errorConfig);
              }).catch(e => {
                customAxios(errorConfig);
                 //exception occurs at this point and getting into loop
                localStorage.setItem('errorMsg', e.response.data.message);
                window.location.href = Constants.ERROR_PAGE;
                return Promise.reject(error);
              }).finally(
                clearPromise(errorConfig)
              );
          } else {   
              return customAxios(errorConfig);
          }
        } else if (errorConfig.retry) {
          return customAxios(errorConfig);
        } else {
         return Promise.reject(error);
        }
      } else {
        return Promise.reject(error);
      }
    } else {
      if (errorConfig.url !== Constants.LOGIN_URL) {
        localStorage.setItem('errorMsg', 'Unauthorized access');
        window.location.href = Constants.ERROR_PAGE;
        return Promise.reject(error);
      } else {
        return Promise.reject(error);
      }
    }
  }
);

when there is exception at backend, my page is keep sending request in loop and not exiting when there is error. issue happen when there is exception in catch block due to “e.response.data.message” is undefined. but i want to stop sending request incase of any exception inside catch block.

Why For isValid upon invalid phone number? [duplicate]

I am doing a simple validation:

document.addEventListener("DOMContentLoaded", () => {
const form = document.getElementById("test");
 if(!form.checkValidity()){
   alert("Error");
 } else {
   alert("ok");
 }
});
<form id="test">
  <input type="email" name="email" value="[email protected]" />
  <input type="tel" name="tel" value="excalibur" />
</form>

But despite excalibur not being a valid phone number still checkValidity returns value as valid. Do you know why that happens?

How to run JS on a WebApp using AppleScript

I saved Youtube Music as WebApp from Safari. I want to create an automation using AppleScript. It should run Javascript code on that WebApp.

I was trying to use something similar to what youtube-music extension does on Raycast.

tell application "${browser.name}"
    repeat with w in (every window)
        repeat with t in (every tab whose URL contains "music.youtube.com") of w
            tell t
                return ${runJS(browser.name, code)}
            end tell
        end repeat
    end repeat
end tell

Link to code

vimeo only seeing one iframe

trying to set up controls for each iframe on the page

import Player from "@vimeo/player";

class VimeoSettings {
constructor(vimeoContainers) {
    

    console.log("Number of vimeoContainers: " + vimeoContainers.length);

    //two vimeoContainers

    vimeoContainers.forEach(container => {
        const iframe = container.querySelector('.vimeoVideo-iframe');
        const playerId = "player-" + iframe.getAttribute("data-id");

        console.log(playerId)
        //only one  iframe

        console.log("Processing iframe with data-id: " + iframe.getAttribute("data-id"));

        // Create a new Vimeo player instance for each video
        const player = new Player("#" + playerId);

        // Add event listener to pause/play the video when clicked
        iframe.addEventListener("click", function() {
            player.getPaused().then(function(paused) {
                if (!paused) {
                    player.pause();
                    console.log("baws")
                } else {
                    player.play();
                    console.log("baws")
                }
            });
        });
    });
}

}

export default VimeoSettings;

this part “below” is only ever showing one frame even if ther eare more than one on page?

console.log(“Processing iframe with data-id: ” + iframe.getAttribute(“data-id”));

Browser console says function not defined but function is there. What am I doing wrong?

I’m writing a webpage where I select an item (to fetch with php all the properties of that item; a molecule to be precise), then after the item is selected the user has a text field where to try and assign a name to the item and within the form there’s also a button labelled “check answer”. When the user presses the button a javascript code should tell the user if they typed in the correct name for the item or not.

I wrote this code, placed at some point inside the page, inside the <body> tag:

<script type="text/javascript">
var molecola {
  itname: <?php echo $mol_data["it"]["nome_comune"]; ?>;
  itname2: <?php echo $mol_data["it"]["nome_iupac"]; ?>;
  enname: <?php echo $mol_data["en"]["nome_comune"]; ?>;
  enname2: <?php echo $mol_data["en"]["nome_iupac"]; ?>;
};

function checknameita(f) {
  if ((f == molecola.itname) || (f == molecola.iname2)) {
    document.getElementById('rispostaita').style.textAlign = 'center';
    document.getElementById('rispostaita').style.color = 'green';
    document.getElementById('rispostaita').innerHTML = 'Corretto';
  }
  else {
    document.getElementById('rispostaita').style.textAlign = 'center';
    document.getElementById('rispostaita').style.color = 'red';
    document.getElementById('rispostaita').innerHTML = 'Sbagliato';
  }
}
</script>

<div class="container">
  <div class="row">
    <div class="col-md-5 borderpad">
      <h5>Nome italiano</h5>
      <form name="nomeita">
        <label>Scrivi il nome della molecola:</label><br>
        <input type="text" name="itname" class="maxwidth">
        <div class="pulsante">
          <input type="button" onClick="checknameita(this.nomeita)" value="Controlla risposta">
          <input type="button" onClick="seeanswerita(this.nomeita)" value="Vedi risposta esatta">
        </div>
        <div id="rispostaita"></div>
      </form>
    </div>
    <div class="col-md-5 offset-md-2 borderpad">
      <h5>Nome inglese</h5>
      <form name="nomeeng">
        <label>Scrivi il nome della molecola:</label><br>
        <input type="text" name="enname" class="maxwidth">
        <div class="pulsante">
          <input type="button" onClick="checknameeng(this.nomeeng)" value="Controlla risposta">
          <input type="button" onClick="seeanswerita(this.nomeeng)" value="Vedi risposta esatta">
        </div>
        <div id="rispostaeng"></div>
      </form>
    </div>
  </div>
</div>

The code is not complete yet, so some functions are missing, but the function checknameita is supposed to be complete, and the button with code <input type="button" onClick="checknameita(this.nomeita)" value="Controlla risposta"> that calls it is there. There might be syntax errors in what I wrote that won’t let the function execute properly (and I can figure them out later), but the main issue that I have is that the function doesn’t run at all at the moment. When I click the button and I have the debugging console open in Firefox, I see this error:

Uncaught ReferenceError: checknameita is not defined
    onclick http://joomla5.test/index.php/it/esercizi/nomenclatura/nomenclatura-struttura-nome?gruppo=1&start=0&molid=1:1

However the function is there, and I think I declared it correctly. What am I doing wrong?

Python Selenium scrape of javascript array

Using Python/Selenium, I’m able to get several pages deep into a password protected website I use for work.

However, I’ve hit a wall with a JavaScript array from which I need to open a drop-down and select the first option.

Here is the location on the page:
enter image description here

Copy JS Path: document.querySelector("#miFavorite")

Copy XPATH: //*[@id="miFavorite"]

And this is the JS:

enter image description here

XPATH: //*[@id="Form1"]/script[3]/text()

How can I select menuItem[0]?