Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
Putting a variable into a form using plain Javascript

This is pretty plain and simple but I'm just scratching my head. I created a form (https://taa.be.wolterskluwer.com/l/940253/2021-10-08/5tgp6n) which contains a field GACLIENTID (I've assigned it the classes GA_Client_ID & GACLIENTID) however since the form is not handcoded the class is assigned to the contacting paragraph (which contains a label & input).

I've successfully pushed my variable using the following script:

<script>
  (function() {
    var list = document.querySelectorAll('input[name="940253_168501pi_940253_168501"]');
    list.forEach(function(el){
      if(el) {
        el.value = {{DL - GA Client ID}};
  }
})
  })();
</script>

But this finds the input with the "name" of the field which changes on every clone of the form I'm creating. So I'm looking for a more "universal" way of selecting the input within the class but I just can't, for the life of me, figure out the correct syntax.

Any help is much appreciated.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

var list = document.querySelectorAll('.GACLIENTID input');
about 4 years ago · Juan Pablo Isaza Report

0

If there's only ever one matching field.

const input = document.querySelector('.GACLIENTID input');

if (input) {
    input.value = {{DL - GA Client ID}};
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!