Webbers Corner

Full Version: Change form colour on click
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

Does anyone know of some javascript which will change the colour of the text when you click on the form to edit it.

hope that makes sense.

dave.
i would like to know this too. i guess it is just normal javascript and not the fancy ajax thing?

bubble Wrote:
i would like to know this too. i guess it is just normal javascript and not the fancy ajax thing?


its definatly just basic js but i suck at it so need help lol.

what about

formElement onclick="document.getElementById('textElementId').style.background='yourColor';"

of onclick="changeColor('textId')"

function changeColor(id){
var textEl = document.getElementById(id);
if(textEl.style.backgroundColor=='color1'){
  textEl.style.backgroundColor=color2;
}else{
  textEl.style.backgroundColor=color1;
}
}
Reference URL's