chris77780124
06-18-2012, 09:28 PM
So I have figured out from a guy on here that this code lets you change the BG Color when certain text is enter into a text field. It works just fine.
But now what I need help with is what Java Script statement do I use if the field has text automatically enter into the field. I need the same thing to happen the BG Color to change a different color depending on what text has been auto filled.
If someone knows what extra code I would need to enter to make this work
Thanks to all who can help.
<body>
<input type="text" name="fld1" id="fld1" onkeyup="changeBG(this.value)"/><br />
<input type="text" name="fld2" id="fld2" onkeyup="changeBG1(this.value)"/><br />
<input tupe="text" name="fld3" id="fld3" onkeyup="changeBG(this.value)"/><br />
<script>
function changeBG(val){
var colors={"AMDML":"red","MA":"green","SPN":"black"};
for(i in colors){
if(val.match(i)){
document.body.style.backgroundColor=colors[i];
}
}
}
</script>
<script>
function changeBG1(val){
var colors={"AMDML":"blue","CA FANNIEMAE MA":"green","BCRA ETRADE":"black"};
for(i in colors){
if(val.match(i)){
document.body.style.backgroundColor=colors[i];
}
}
}
</script>
</body>
But now what I need help with is what Java Script statement do I use if the field has text automatically enter into the field. I need the same thing to happen the BG Color to change a different color depending on what text has been auto filled.
If someone knows what extra code I would need to enter to make this work
Thanks to all who can help.
<body>
<input type="text" name="fld1" id="fld1" onkeyup="changeBG(this.value)"/><br />
<input type="text" name="fld2" id="fld2" onkeyup="changeBG1(this.value)"/><br />
<input tupe="text" name="fld3" id="fld3" onkeyup="changeBG(this.value)"/><br />
<script>
function changeBG(val){
var colors={"AMDML":"red","MA":"green","SPN":"black"};
for(i in colors){
if(val.match(i)){
document.body.style.backgroundColor=colors[i];
}
}
}
</script>
<script>
function changeBG1(val){
var colors={"AMDML":"blue","CA FANNIEMAE MA":"green","BCRA ETRADE":"black"};
for(i in colors){
if(val.match(i)){
document.body.style.backgroundColor=colors[i];
}
}
}
</script>
</body>