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

122
Views
change css based on js variable

I am passing a variable called editable from my backend, which holds true or false as the variable. once it is passed to the front end, i have access to it. I want to do something like this:

if ('<%= editable %>' == true) {
 //change the input tag (in css) to be able to be edited.
}

i have this code in the <style> tag:

input {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;  
}

how can I do this?

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

0

Appreciate everyone's comments. I have figured out a very viable solution for this, hopefully it can help everyone in the future.

function test () {
  if ('<%= editable %>' != 'yes') {
    var x = document.getElementsByTagName("input");
      for ( var counter = 0; counter < x.length; counter++){
         x.item(counter).readOnly = true
      }
   }
}

and then onload="test()" in the body tag.

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!