phinix
Gawd
- Joined
- Dec 13, 2005
- Messages
- 884
To explain it as simple as it is:
I have special characters buttons on website, lets say 20 different buttons with french alphabet special characters.
Now, I have input text field, where user tapes his answer to a question listed above. When he needs to use special character he clicks on the approprietsfsf button with that character, and it appears in text field after the string he taped.
problem I have is - how to do it for all button? I can direct the value of one button to that field by simply "MyElement.value = MyElement.value + button.value;"
But now how can I add it when user clicks different button? How to change that button.value to actually button id that he clicked?
OK.. here's what I've got so far:
list of buttons (just few here to show how they look)
.. text field:
Now, the function:
So question is - how to change that "aacute.value" to "clickedbutton".value?
it has to be easy, but I'm total noob in javascript, so please help me out here!
I have special characters buttons on website, lets say 20 different buttons with french alphabet special characters.
Now, I have input text field, where user tapes his answer to a question listed above. When he needs to use special character he clicks on the approprietsfsf button with that character, and it appears in text field after the string he taped.
problem I have is - how to do it for all button? I can direct the value of one button to that field by simply "MyElement.value = MyElement.value + button.value;"
But now how can I add it when user clicks different button? How to change that button.value to actually button id that he clicked?
OK.. here's what I've got so far:
list of buttons (just few here to show how they look)
Code:
<input type='button' value="á" id="aacute" onclick="AddChar()"/>
<input type='button' value="à" id="agrave" onclick="AddChar()"/>
<input type='button' value="â" id="acirc" onclick="AddChar()"/>
<input type='button' value="ä" id="auml" onclick="AddChar()"/>
.. text field:
Code:
<input type="input" id="myfield"></input>
Now, the function:
Code:
function AddChar()
{
var MyElement = document.getElementById("myfield");
MyElement.value = MyElement.value + aacute.value;
return true;
}
So question is - how to change that "aacute.value" to "clickedbutton".value?
it has to be easy, but I'm total noob in javascript, so please help me out here!