jamiller
05-03-2007, 02:22 PM
So I have 6 buttons and when they are clicked I need a textbox to be populated with each of the buttons values.
Here is the code I have so far:
for(var i = 1; i<=6; i++) {
var med = document.getElementById('med'+i).innerHTML;
document.getElementById('TextBox1').value = med;
}
I should mention that this is all encapsulated within a function that is called when the user clicks on a button. And obviously the textbox does populate but not with the current button's value, unless you click on the last button. And these "buttons" I refer to are spans with onclick hence why I'm using innerHTML.
In Flash I would do it like this:
for(var i = 1; i<=6; i++) {
var med = document.getElementById('med'+i);
med.ih = med.innerHTML;
document.getElementById('TextBox1').value = this.ih;
}
But the textbox populates with "undefined."
Thanks again for everybody's help :)
Here is the code I have so far:
for(var i = 1; i<=6; i++) {
var med = document.getElementById('med'+i).innerHTML;
document.getElementById('TextBox1').value = med;
}
I should mention that this is all encapsulated within a function that is called when the user clicks on a button. And obviously the textbox does populate but not with the current button's value, unless you click on the last button. And these "buttons" I refer to are spans with onclick hence why I'm using innerHTML.
In Flash I would do it like this:
for(var i = 1; i<=6; i++) {
var med = document.getElementById('med'+i);
med.ih = med.innerHTML;
document.getElementById('TextBox1').value = this.ih;
}
But the textbox populates with "undefined."
Thanks again for everybody's help :)