0
Display name of textbox
I have multiple text boxes on a form and I want to display the name of the textbox when I click on it in a specific textbox. As I have 300 textboxes I dont want to create 300 click Events. Do I need some kind of loop
1 ответ
+ 1
You could give each text box its own id if you haven't already, give the display box an id too, then write a function that sets the text of the display box to something like this.idOfTextBoxYouClicked. All you have to do is set the id of the text box you're focused on as the text of the display box.
Or, you could even put them in a div together, and apply the onclick to the div (but I think you might have to target the id differently by traversing the DOM - maybe target child elements of the div?)