473,320 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using OnClick to display message in textbox

I want to add onClick() on a textbox which is dynamically generated in a table using following java script method.i just want to call a java script method which will get generate through this code.
suppose i want to show a message "hi" if anybody click on the textbox generated with this code.


Expand|Select|Wrap|Line Numbers
  1.   function addRow()
  2.   {
  3.  
  4.  var tbody = document.getElementById("table2").getElementsByTagName("tbody")[0]; 
  5. var row = document.createElement("TR"); 
  6. var cell1 = document.createElement("TD"); 
  7. var inp1 =  document.createElement("INPUT"); 
  8. inp1.setAttribute("type","text"); 
  9. inp1.setAttribute("name","game_"+count);
  10. inp1.setAttribute("id","game_"+count);
  11. inp1.setAttribute("maxlength",11);
  12. inp1.setAttribute("size",10);
  13. inp1.setAttribute("value",document.forms.form1.elements.game.value); 
  14. cell1.appendChild(inp1); 
  15. var cell2 = document.createElement("TD"); 
  16. var inp2 =  document.createElement("INPUT");
  17. inp2.setAttribute("type","text"); 
  18. inp2.setAttribute("name","number_"+count);
  19. inp2.setAttribute("id","number_"+count);
  20. inp2.setAttribute("maxlength",11);
  21. inp2.setAttribute("size",10);
  22. cell2.appendChild(inp2); 
  23. row.appendChild(cell1); 
  24. row.appendChild(cell2); 
  25. }
Sep 20 '06 #1
1 4140
acoder
16,027 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. inp2.onclick = function() { alert('hi'); }
May 14 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Gary | last post by:
Hello, Is it possible to dynamically update a textbox with words chosen from a list using form checkboxes and javascript? Gary
7
by: Tom | last post by:
I know how to use these great controls. They work very well. But is there a method or property I can use to set the focus to the field that is in error. For example... If I have a page with 5...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
1
by: c.verma | last post by:
I am not able to hide a href element using javascript. Here is my code written on aspx page. On the click of "OK" button, I want to hide href element. But I am getting message: Object required....
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
1
by: OceanBreeze | last post by:
I am using ASP 2.0 and C# I have a TextBox control in .aspx file. <asp:TextBox ID="CityTxt" runat="server"></asp:TextBox> When I click on that text box, I want to trigger onClick event. ...
4
by: itsnidhu | last post by:
Hi this is nidhi from india, Since last 2 days i am facing a problem in asp.net code. The data base connection is done correctly as i can select the data from the database. But i can not insert...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.