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

118
Views
I want to upload random script.js files into one script tag?

I want to upload random script files into a script tag element. I Have tried this but it didn't work.

var randomTest = Math.floor(Math.random() * 5) +1; //generating random number
var randomTestJs = "test" + randomTest + ".js"; // targeting random question file source
var questionSource = "js/" + randomTestJs; //selecting question file source
var test = document.querySelectorAll("script")[0]; //selecting tag attribute
test.setAttribute("src", questionSource); //overwriting question file
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

this can't work. the script tags are executed when the side will be loaded. you try to run the scripts on the fly. this is not the way it works.

perhaps you try to load your questions in a json format with fetch and than work with it.

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!