I want to set a text fields value to whatever's there plus something else when they push a button, basically, add onto what's currently in the box.
I've done the following but it sets the boxes value to "undefined"
It creates nine buttons, then when one is pushed, the corresponding value should be added to the answer box. (I am making a calculator to learn PHP)
PHP Code:
echo "<input type=\"text\" id=\"answer\" size=\"21\" readonly=\"readonly\"></br>";
for($i=0; $i<10; $i++){
echo "<input type=\"button\" value=\"" . $i . "\" name=\"Cal_" . $i . "\" style=\"width:" . $width . "px;height:" . $height . "px\" onClick=\"document.getElementById('answer').value=document.getElementById('answer').value" . $i . "\">";
}
I didn't know where to post this as the onClick is Java and the rest is PHP so I guessed here.