This question has already been answered:

Good day. The question is. On a third-party site there is a form in which there is a checkbox , like using javascript to select the checkbox I need when using the built-in application in mozilla Простой редактор javascript . Here is a piece of the form from the site.

 <input type="checkbox" class="form-checkbox" title="Отметить все колонки таблицы"> 

Reported as a duplicate at Grundy. javascript May 29 '17 at 11:01 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • instead of type="checkbox" write type="radio" and you can always choose only one of them. - Raz Galstyan
  • @RazmikGalstyan I am sorry, you probably misunderstood. It is necessary, that would select the necessary checkbox when using my code on a third-party site. - yuriyurekt
  • @yuriyurekt, edit the question by adding all the necessary information. Now it is not clear what you want to do. You can edit the question using the edit button questionable - Grundy
  • @yuriyurekt Well then you didn’t ask the question correctly, let’s explain in detail, correct the question. - Raz Galstyan
  • one
    @RazmikGalstyan I wrote before editing my question that I am a user in js. Honestly, I read how to do it, but did not come to the exit from this situation. I can not stand to ask questions on this site, because here all are too "passionate users." Always sticking someone, carping, such as you are now. What is stopping you from pushing this answer? After all, no one forces you to go into this question and answer. In the same point, if a person does not understand, he asks. If you find it difficult to answer this question, pass by. Boiling hot. - yuriyurekt

1 answer 1

Here is an example of a simple JavaScript code that will solve your question: As I understand from our discussion in the chat, you have a structure like this on a third-party site:

 <th class="select-all"> <input type="checkbox" class="form-checkbox" title="Отметить все колонки таблицы"> </th> 

You need to choose this checkbox :

From the code it is clear that we can select it according to the class of its parent class="select-all" .

And then there are just 3 lines of Javascript code, the first line selects the parent, the second one looks for the checkbox itself that you need, and the third line supplies the птичку (selects your checkbox )

 var tmp_th = document.getElementsByClassName('select-all'); var my_checkbox = tmp_th[0].childNodes[1]; my_checkbox.setAttribute("checked", "checked"); 

If you want to check that you have selected the desired item, just write the following line after the code: console.log(my_checkbox); and you will see the selected item in the console.