getting focused control and setting different message in text box.
-
Hi All, I would like to get some ideas about for the java script as I am new to that area. I'd like to set up a script which will get the control id which is being focused and according to the control id I'd like to set a different message to a text box. If you have any link or ideas of your own, please share with me. The logic is I will have like 6 or 7 controls on the page with a master page.(I am using MS AJAX) When user changes the focus from control to control I would like to display the message in a text box. Like...If the focus is on textbox 1 The message will be "this is text box 1". And user changes the focus to textbox 2 , The message will be " This is text box2." please give me a hand.
-
Hi All, I would like to get some ideas about for the java script as I am new to that area. I'd like to set up a script which will get the control id which is being focused and according to the control id I'd like to set a different message to a text box. If you have any link or ideas of your own, please share with me. The logic is I will have like 6 or 7 controls on the page with a master page.(I am using MS AJAX) When user changes the focus from control to control I would like to display the message in a text box. Like...If the focus is on textbox 1 The message will be "this is text box 1". And user changes the focus to textbox 2 , The message will be " This is text box2." please give me a hand.
Hi, this can simply be achieved by utilising the
onfocus
andonblur
DOM events that controls such as textboxes expose. To hook up your controls to these events you would do something like the following: In your ASPX page:<asp:TextBox id="textBox1" runat="server" onfocus="showMessage('This is textBox1');" onblur="showMessage('');" /> <div id="messageHolder"></div>
In your JS file (or simply in a script block on your ASPX page)function showMessage(message) { document.getElementById('messageHolder').innerHTML = message; }
Clean code is the key to happiness.
-
Hi, this can simply be achieved by utilising the
onfocus
andonblur
DOM events that controls such as textboxes expose. To hook up your controls to these events you would do something like the following: In your ASPX page:<asp:TextBox id="textBox1" runat="server" onfocus="showMessage('This is textBox1');" onblur="showMessage('');" /> <div id="messageHolder"></div>
In your JS file (or simply in a script block on your ASPX page)function showMessage(message) { document.getElementById('messageHolder').innerHTML = message; }
Clean code is the key to happiness.
Thanks for your help. It works.