I have asked a few questions related to this, and all were answered very well, so im hoping to get some more good answers related.
I have 9 buttons on a page, with text inputs. When a user clicks the one of the buttons, the text that they put into the text input field, is transferred to another text box on that page, but I also want that button to change colors.
So what I have for my html, is this:
<input id="fbvalbox" type="text" placeholder="Your personal message" />
<input id="butval1" class="butz" type="button" name="design1" value="Choose Design" onclick="changeID(this);" />
That is one text box, and a button. So, here is my other box, that I want the message that is entered in that box, to this one.
<input id="design_choice" type="text" value="" />
Now for my javascript, this is my script that transfers the message, to my design choice text box.
window.onload = function(){
document.getElementById('butval1').onclick = function(){
document.getElementById('design_choice').value = document.getElementById('fbvalbox').value;
}
That works great, but I also want the button to change colors.
So, I added the onclick="changeId(this)" to the first box, and it didn't work. this is a seperate .js file, but also in the head of the page.
function changeID(elm){
var NAME = elm;
var currentClass = NAME.className;
if (currentClass == "butz") {
NAME.className = "butzz";
} else {
NAME.className = "butz"; }
Now, if I use that alone, it works great, but I want to execute both of these onclick. The first one, I have written out for it to transfer the value by the Id. and the second js, is written to change the css class
I want both to run. Any help is much appreciated.
thank you