473,786 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OnChange event for dynamic textbox

18 New Member
Hi
I m creating a textbox dynamically on click of a button. I want to attach an onChange event for that textbox.I tried using following code but it does not seem to work.Can anyone suggest a better way to solve my problem. The code i am using is as follows:

Expand|Select|Wrap|Line Numbers
  1.  var cell1 = row.insertCell(0);
  2.   var addRowTextNode1 = document.createElement('input');
  3.  addRowTextNode1.setAttribute('type','text','name','UI'+iIteration,'id','UI'+iIteration);
  4. addRowTextNode1.onChange=function callChange(){alert('Hi');};
  5.   cell1.appendChild(addRowTextNode1);
Thanks
daitasri
Mar 4 '08 #1
2 5734
SharpDeveloper
12 New Member
function CreateBox()
{

var addRowTextNode1 = document.create Element('input' );
addRowTextNode1 .setAttribute(' type','text','n ame');
var x=document.getE lementById('for m1')

x.appendChild(a ddRowTextNode1) ;
myOnChange = new Function("e", "callChange()") ;
addRowTextNode1 .onchange=myOnC hange ;


}
function callChange()
{alert('Hi');};

Hope this helps!
Hi
I m creating a textbox dynamically on click of a button. I want to attach an onChange event for that textbox.I tried using following code but it does not seem to work.Can anyone suggest a better way to solve my problem. The code i am using is as follows:

Expand|Select|Wrap|Line Numbers
  1.  var cell1 = row.insertCell(0);
  2.   var addRowTextNode1 = document.createElement('input');
  3.  addRowTextNode1.setAttribute('type','text','name','UI'+iIteration,'id','UI'+iIteration);
  4. addRowTextNode1.onChange=function callChange(){alert('Hi');};
  5.   cell1.appendChild(addRowTextNode1);
Thanks
daitasri
Mar 4 '08 #2
rnd me
427 Recognized Expert Contributor
in firefox, you may often find it handy to use

Expand|Select|Wrap|Line Numbers
  1.  elmTextarea.setAttribute("onchange", "alert('function code goes here')"
  2.  
Mar 4 '08 #3

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

Similar topics

1
20701
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function init() {
4
4089
by: Zeebra3 | last post by:
Here goes: I have a web form with several asp:dropdownlists, with which, when selection is changed I want to fire an event defined in some clientside js. The content of the clientside code is dependant on data collected in the code behind on the server. I have set AutoPostback to false for the controls and added lines such as cboMyCombo1.Attributes.Add("onchange", "MyCombos_OnChange('1')"); in the Page_Load event, which is rendered OK...
1
6598
by: Kathy Burke | last post by:
Hi, I have a textbox and a calendar popup window. I got this from a posting (sorry, his name escapes me at the moment). It's nice and simple, so I like it, of course. Only problem I have is that when the popup closes and puts the control value (date selected) into the textbox on my main form, I can't get my onchnage event to fire (i.e., which should load a datagrid). This is the sub that the calendar pop-up form uses when the date is...
7
3408
by: Peter | last post by:
Does anyone know how to trap SelectedIndexChanged event on the client side for the following control? http://www.metabuilders.com/Tools/ComboBox.aspx I have tried MyComboBox.Attributes.Add("OnChange", "return IndexChanged();"); but OnChange event never fires Thanks
2
3935
by: pendragn | last post by:
I've come across a problem I just can't solve. I have an text element I need to evaluate on change. All I need to do is open a confirm dialog asking if they'd like to save the change, if yes, I save the change and move on, if no the textbox needs to revert to it's original value. All of this works wonderfully as long as the browser window keeps focus durring the onchange event. However if the window looses focus triggering the onchange...
5
6502
by: subhodey | last post by:
Hello, I have a ColdFusion online application that has a page having 2 textboxes. Corresponding to these 2 textboxes I have a Custom tag in coldfusion where the textbox is defined by <input type=text .....>. In the onChange event a coldfusion attribute is called (like, onChange="#attributes.onChange#"). Now in the cold fusion page the 2 textboxes are defined using the single Custom tag with different name (say m and x). On the onChange...
21
29821
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays prodcut anme have used ajax to avoid refreshing of page this works fine 2.now i have created one row with checkbox|select box|text|text|text|text| where in the select box values are fetched from table here also i have used ajax for getting the m_name...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.