Make a button off with jQuery

Make a button off with jQuery

Hi,I have a project that I have made a web application that shows some buttons which interact with the client and accordingly to the values of the buttons, it makes changes on the server such as: if you turn on a button on the site, on the server you can see a led on...and so on.What I want to do now is upon a value (that is displayed as well on the site) put the button off and keep it there for secure reasons lets say...the code for the buttons is above
  1. "<script>"
  2.     "$(document).ready(function(){ $('#red').bind( 'change', function(event, ui) { jQuery.ajaxSetup({timeout: 1000}); var id = $(this).attr('id'); var strength = $(this).val(); if (id == 'red') $.post('/remote', { red: strength } ); });});"
  3.   "</script>"   
  4.       "<div data-role=\"fieldcontain\">"
  5.          "<h2>LED</h2>"
  6.          "<input type=\"range\" name=\"slider\" id=\"red\" value=\"0\" min=\"0\" max=\"255\"  />"
  7.       "</div>" ;   
what I think I should add in order to make it work like what I mentioned before is sth like that what do you think?
  1. if (tempC>20){
  2.         "<script >"
  3.       "$(document).ready(function(){ $('#red').val()=0; var strength=$(#red).val(); $.post('/remote', { red: strength } )"};
  4. "</script>"
  5. };
it is a informal version. Someone suggested that I should work with setInterval or setTimeout functions though  what do you think about?
thank you