R
R
Rostyk Ice2018-03-21 14:29:07
JavaScript
Rostyk Ice, 2018-03-21 14:29:07

Inline js doesn't see inputs in WP admin, what could be the problem?

Hello everyone!
I ran into a problem in working with the script, or rather with WP.
I made a script that creates an input on the admin page in order to enter a number into it, and he registered the yurl in other inputs according to the template
:

JS
$('body').append('<input type="text" name="mod" id="mod" placeholder="URL" >')
  $("#mod").css("position", "absolute").css("top", 643).css("left", 281);
  $("#mod").on( "change",function () {
  $('#widget-sow-button-c52-url').val($('[name="mod"]').val());
  $('#widget-sow-button-c60-url').val($('[name="mod"]').val());
  $('#widget-sow-button-c50-url').val($('[name="mod"]').val());
  $('#widget-sow-button-c50-url').val("/wp-content/uploads/2018/02/Graphics_and_illustrations/Soc_media_WEB/gs" + $('[name="mod"]').val() + "_original.zip");
  $('#widget-sow-button-c52-url').val("/wp-content/uploads/2018/02/Graphics_and_illustrations/Soc_media_WEB/gs" + $('[name="mod"]').val() + "_eng.jpg");
  $('#widget-sow-button-c60-url').val("/wp-content/uploads/2018/02/Graphics_and_illustrations/Soc_media_WEB/gs" + $('[name="mod"]').val() + "_ua.jpg");
  $('#dcmsefi_url').val("/wp-content/uploads/2018/02/Graphics_and_illustrations/Soc_media_WEB/gs" + $('[name="mod"]').val() + "_ua.jpg");
  $('[name="post_title"]').val("gs" + $('[name="mod"]').val());
 });

He does everything BUT when I enter a number, he changes the value only in visible inputs, and he does not change those that need to be opened. (although they are on the page
f12
5ab241acef5e8927634795.png
)
example:
spoiler
5ab23d86bbab3370564439.png5ab23d8eb88b7264830579.png

He does not fill in because he does not see them, he decided everything with a crutch:
crutch
$('body').append('<input type="button" value="Н" id="btn6" accesskey="ф" style="border-width: 0px; background: url(images/opacity.png);">')
  $("#btn6").css("position", "absolute").css("top", 300).css("left", 600).css({ color: "red" });
  $('#btn6').click(function(){
      $('#widget-sow-button-c52-url').val($('[name="mod"]').val());
  $('#widget-sow-button-c60-url').val($('[name="mod"]').val());
  $('#widget-sow-button-c50-url').val($('[name="mod"]').val());
  $('#widget-sow-button-c50-url').val("/wp-content/uploads/2018/02/Graphics_and_illustrations/Soc_media_WEB/gs" + $('[name="mod"]').val() + "_original.zip");
  $('#widget-sow-button-c52-url').val("/wp-content/uploads/2018/02/Graphics_and_illustrations/Soc_media_WEB/gs" + $('[name="mod"]').val() + "_eng.jpg");
  $('#widget-sow-button-c60-url').val("/wp-content/uploads/2018/02/Graphics_and_illustrations/Soc_media_WEB/gs" + $('[name="mod"]').val() + "_ua.jpg");
   });

Outcome:
  1. I open the page
  2. put number into input
  3. I go through all the "languages" of the buttons, open it and press alt + f to change the value
  4. save

Ideally, there should be 3 points and 2 seconds of work.
I wanted to simplify filling in the content, but anyway you need to open each button to change the url, I simplified it only at the copy-paste level, but I would like to just enter the number and save it, and not press a bunch of buttons, since there is a lot of content.
Here's what the buttons look like at the client level:
spoiler
5ab23e8a67a22338104647.png

If you need additional information, I will write, otherwise I don’t know what input parameters are needed to solve the problem.
Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question