424,294 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,294 IT Pros & Developers. It's quick & easy.

how to change the texbox color if checked radio button javascript

P: 1
Can you help to do it correct


Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.  <td>class</td>
  3.  <td><input name="class"type="radio" onClick="enableElement1(this.form.work_permit);"/></td>
  4.  <td><input name="class"type="radio" onClick="enableElement2(this.form.work_permit);"/></td>
  5.  <td><input name="class"type="radio" onclick="disableElement(this.form.work_permit);"/></td>
  6.  <td><textarea  for="work_permit"name="comments"rows="4"cols="20"></textarea></td>
  7.  </tr>
  8.  
  9. <script>
  10.  function disableElement() {
  11.   text.value = ' - N.A. - ';
  12.  obj.disabled= true; 
  13.  
  14.  function enableElement1(obj) {
  15.   obj.value = '';
  16.   obj.disabled = false;
  17. }
  18. function enableElement2(obj) {
  19.   obj.value = '';
  20.   obj.disabled = false;
  21. }
  22.  
  23.  </script>
  24.  <style>
  25.  enableElement1{
  26.  color:green;
  27.  }
  28.  enableElement2{
  29.  color:red;
  30.  }
  31.  </style>
2 Weeks Ago #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,204
to set the color (= textcolor) with javascript you could use:

Expand|Select|Wrap|Line Numbers
  1. obj.style.color = 'your-intended-color';
or you can set a css classname like:

Expand|Select|Wrap|Line Numbers
  1. obj.className = 'your-intended-classname';
2 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.