You need to sign in to do that
Don't have an account?
ksmo
Button should change color based on when text is entered
Hi,
I have a button which is a div element. The css for this button is that it is grey in color.
<div class="UpdateButton"> UPDATE </div>
When text is inputted in the text box the color of the button should change to red.
<div class="textpanel"> <input type="text" size="35" /><br/></div>
Similrly ther eis a checkbox on visualforce componenet which is referenced on the visualforce page. If that checkbox is checked the button should change to red.
I have a button which is a div element. The css for this button is that it is grey in color.
<div class="UpdateButton"> UPDATE </div>
When text is inputted in the text box the color of the button should change to red.
<div class="textpanel"> <input type="text" size="35" /><br/></div>
Similrly ther eis a checkbox on visualforce componenet which is referenced on the visualforce page. If that checkbox is checked the button should change to red.
You can use the following code,
<div class="UpdateButton"> UPDATE </div>
When text is inputted in the text box the color of the button should change to red.
<div class="textpanel">
<input type="text" size="35" onchange="changeColor();"/><br/>
</div>
<script>
function changeColor(){
document.getElementByClass("UpdateButton").background-color = red;
}
</script>
- Hope this helps
All Answers
You can use the following code,
<div class="UpdateButton"> UPDATE </div>
When text is inputted in the text box the color of the button should change to red.
<div class="textpanel">
<input type="text" size="35" onchange="changeColor();"/><br/>
</div>
<script>
function changeColor(){
document.getElementByClass("UpdateButton").background-color = red;
}
</script>
- Hope this helps
This worked when I changed the
<div id="UpdateButton"> UPDATE </div>
function changeColor(){
document.getElementById("UpdateButton").background-color = red;
}
Thanks!