html – Identify what element got clicked on a form in JavaScript

I am trying to pass a ref to a function so that I know which html element was clicked. If I don’t pass the ‘this’ (and remove the ()’s from the html) it will always only hide the top TR. I need it to hide it’s own TR. BUT, and this is a big BUT, I will not know what row has the “click me” text so hard coding a unique id is not an option. They will all have the same ‘id’ (an array of IDs), or no ‘id’ at all (array of rows).

<!DOCTYPE html>
    <tr id="row()"><td>Hello 1</td></tr>
    <tr id="row()"><td>Hello 2</td></tr>
    <tr id="row()"><td><p onclick="myFunction(this)">Hide me.</p></td></tr>
    <tr id="row()"><td>Hello 1</td></tr>
    <tr id="row()"><td>Hello 2</td></tr>
function myFunction(elmnt) {
 document.getElementById("row(elmnt???)").style.display = 'none';

css – Position text inside ahref element (in center of image)

I created a static block with the following issue:

I’m trying to center text inside an ahref element, which looks like the following;

    <div class="small-24 medium-16 cell">
    <a title="Chairs" href="/chairs"><img src="{{media url="wysiwyg/chair-1.png"}}" alt="Chairs" width="830" height="325">Chairs</a>

Normally, I would position it as follows, with the text in a span in the ahref element next to the img:

a {
   position: relative;
span {
position: absolute;
bottom: 10px;
left: 10px;

However, I’m not allowed to save the span tag inside the ahref element next to the image. See image underneath.
enter image description here

How can I position the text inside the ahref element over the image?

navigation – Make Audio Element Persistent Across Pages

I’m making a radio site and as part of that there’s a listen live element which uses an audio plugin. When the user clicks on a navigation item to bring them to a new page the audio stops (understandably).

Is there a way to keep the audio playing smoothly?

divide and conquer – Clarification on the algorithm for finding a majority element

When the size of your problem reduced to 2, it’s the base case of your
recursion, it’s false that we pair up two remaining elements. so it’s
sufficiently, first count number of occurrence of two remaining
elements in $A$.

for your problem we act as follow:

we check the whole array to count number of occurrence $A(i)=3$, and
number of occurrence of $A(i)=1$ and then if number of occurrence
$3geq frac{n}{2}+1$ or if number of occurrence $1geq frac{n}{2}+1$, we print it.

but the main problem is we must prove the correctness and running time of algorithm.

Suppose $mathcal{X}$ is majority element, because of, $mathcal{X}$ is majority element, then the number of occurrence of it, is grater than
$frac{n}{2}$, so after pair up, at least there is one pair that elements are $mathcal{X}$, otherwise it contradict with this fact that $mathcal{X}$ is majority element.

On the other hand, at most all elements of array $A$ be $mathcal{X}$, so both elements of a pair be equal, as a result at most half of the elements remain in each recursion.

Therefore one of the at most $frac{n}{2}$ elements be $mathcal{X}$. And we do our divide an conquer the problem until remain only two element.

Our statement holds only if $A$ contains $mathcal{X}$. So after we get base that $n=2$, it’s sufficient to for each of two remaining elements we check number of occurrence it.

Suppose the remaining elements is a,b:

  for i = 1 to n
     if (a==A(i))
     if (b==A(i))

 if(a> n/2)
   print a
 else if (b> n/2)
   print b
   print "there is no majority in the array"

Because at each iteration at most half of the elements are remain

Note that at each iteration pairing up of $n$ elements need $O(n)$ time.

finite element method – Multiphysics – Electrostatics and Heat Transfer – Joule Heating boundary conditions

I am working on a multiphysics problem involving electrostatics (direct current) and heat transfer. I was messing around with the Joule Heating tutorial case and need to answer some questions to apply this to my problem.

The tutorial uses Dirichlet boundary conditions for the voltage. How could you calculate the corresponding electric current going through the system? Would you just integrate the electrical conductivity multiplied with the voltage gradient over the boundary surfaces?

If the above regarding the calculation of the current is correct, I assume, I could use the electric current as boundary condition by setting the required voltage gradient at the boundary?

Unfortunately my problem is far more complex than the tutorial as it involves very large temperature gradients, hence the thermal and electric conductivities can not be considered constant. I’ve been looking at other multiphysics problems (Buoyancy driven flow) and noticed, I can combine the electric pde with the heat pde to be solved coupled with ndsolve.

However, I can’t use static boundary conditions for the voltage gradient as the conductivity changes with the temperature field. I was thinking, I could use a WhenEvent to calculate the required voltage gradient at the boundary from the desired current by integrating the electric conductivity over the boundary’s surface at the beginning of each step. Is this the way to go on this, or is there a more elegant solution to this?

react.js – not able to give proper css to my bootstrap element in react

when creating a navigation bar in my react based website , the react code :
 this is the code

 `<ul className="navbar-nav ml-auto mb-2 mb-lg-0">`


now, on the ul tag (line 28) () i want to give margin right auto (mr-auto) instead of (ml-auto) which is margin-left :auto but it is not working and i had already import all necessary bootstrap import in my index.js file in react . and i copied this code from bootstrap itself under components > navbar

How to hide a form element when a datetime widget is filled using #states

The following code is working well to hide a button when a textfield is filled, but it is not working when a datetime widget is encoded:

$form('my_button') = (
  '#type' => 'container',
  'submit' => (
    '#type' => 'submit',
    '#value' => t("Click on me"),
    '#submit' => ('submit_me')),
    '#states' => (
      'visible' => (
        ':input(data-drupal-selector=selector-of-my-text-field)' => ( 
          'filled' => FALSE,

Any hint?

entities – Managed file element in custom field module doesn’t save target id

I have been breaking my head on this issue for a few days now. Using Drupal 9.2.x, I am building a custom field module for a client that has multiple fields. I isolated the problem by only including a managed file field for now, because the other fields are not causing this issue.

I defined a managed file element in my Widget class, which extends WidgetBase:

public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {

    $element('target_id') = (
      '#type' => 'managed_file',
      '#title' => $this->t('Right image'),
      '#upload_location' => 'public://disco-field-images/',
      '#upload_validators' => array(
        'file_validate_extensions' => array('gif png jpg jpeg')
      '#default_value' => array($items($delta)->target_id),

    return $element;


I defined my schema as follows in my Item class:

 public static function schema(FieldStorageDefinitionInterface $field_definition) {
return (
  'columns' => (
    'target_id' => (
      'description' => 'The ID of the file entity',
      'type' => 'int',
      'unsigned' => TRUE,
  'indexes' => (
    'target_id' => ('target_id'),
  'foreign keys' => (
    'target_id' => (
      'table' => 'file_managed',
      'columns' => ('target_id' => 'fid'),


And finally, I have added a property defintion for the field:

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {

$properties('target_id') = ListDataDefinition::create('integer')
  ->setLabel(t('target ID'))

 return $properties;


Somehow this results in the file being uploaded into the managed files table, getting a fid and all looks well from there. However, the field table (node__fieldname) which contains the referencing target_id to the file_managed table somehow always defaults to 1. So no reference is being made to the uploaded file. I have tried working with other property definitions:

    $properties('target_id') = DataDefinition::create('integer')
  ->setLabel(t('target ID'));


$properties('target_id') = DataReferenceTargetDefinition::create('integer')
 ->setLabel('Foreign key referencing managed file')
 ->setSetting('unsigned', TRUE)

But no luck there. It seems a bit weird to me though, that the database target id needs to be integer and the file upload widget works with an array. Thats why I am aiming at the property definitions/schema as a cause here. If I try to work with a single int property value:


I get a primitive type error because the managed file element expects an array. Any suggestions? Thanks!

How to replace the number of each element of a matrix with a subscript?

I want to get the matrix as Figure 2. There should be two ways to achieve the result.

  1. There is a matrix as Figure 1, and change it to the form of Figure 2.

  2. Generating the matrix as Figure 2 directly.

How can I do it? Thanks.

Figure 1

enter image description here

Figure 2

enter image description here



layout – Broken reference: No element found with ID ‘sidebar.main’. [] []

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.