473,654 Members | 3,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create a table dynamically

31 New Member
hi ,

I am developing a system using javascripts and ajax.
I am retrieving data from database and bind them in an html table. I am using a for loop to do this. This table has one column of html buttons. my task is to call a function when a user press the button in a row. this function will call an ajax method to bring some data fro the database. I have to pass a value to this function when a user press the button. this value is unique to each raw.

this is the part code i am trying;


Expand|Select|Wrap|Line Numbers
  1. // in the for loop
  2.  
  3.      btn=document.createElement('INPUT');
  4.          btn.type='button';
  5.           btn.value=Dset.value.Tables[0].Rows[a].CusCode;
  6.  
  7.          btn.onclick=function CustomerClick()
  8.               {
  9.                  // function will bring data                 
  10.                };
  11.  
  12. //
  13.  
this is the place i got the problem. I want to pass that 'CusCode' value to the function as avariable. this 'CusCode' is unique to each raw. when the user press the button it should call the function with it's unique variable.

can anyone help me to solve this?
Mar 13 '08 #1
3 1500
gits
5,390 Recognized Expert Moderator Expert
try this:

Expand|Select|Wrap|Line Numbers
  1. var btn = document.createElement('INPUT');
  2. btn.type = 'button';
  3. btn.value = Dset.value.Tables[0].Rows[a].CusCode;
  4.  
  5. btn.onclick = function(value) {
  6.     return function() {
  7.         // here use value which is the closured btn.value
  8.     };
  9. }(btn.value);
  10.  
kind regards
Mar 13 '08 #2
anudu
31 New Member
wow, it works perfectly. Thank you very much.
Mar 14 '08 #3
gits
5,390 Recognized Expert Moderator Expert
no problem :) .... post back to the forum anytime you have more questions ...

kind regards
Mar 14 '08 #4

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

Similar topics

7
3520
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET) template. Briefly -------------------------------------------------------------------------------------------- I need to create dynamically some controls on the forms, and display these
4
4433
by: Michael Jackson | last post by:
I have a stored procedure to create a table. In my program I want the user to name the table to be created, therefore I pass a parameter to the SP for the table name. I cannot get it to work. It creates a table called "@NewTableName". Any ideas? CREATE PROCEDURE dbo.sp_FFProduction_CreateTable (
3
10795
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would then like that, when clicking the LinkButton, the user can be navigated to another page, carrying a variable. I would like to use server.transfer method instead of QueryString as I don't want the carried variable to be visible for the user.
3
2969
by: RSB | last post by:
Hi Every one Having tuff time creating web controls Dynamically. All i am trying to do is read a table and generate a list of ASP TEXT Box. So how do i create this Control dynamically and where do i add the EventHandler to it. Thanks RSB
0
1085
by: tommy | last post by:
hello everybody, i haved read a few articles about, how to create controls in asp.net dynamically! i have tested it -- all works fine.... but....now it comes--> HOW create controls dynamically using a html-table.... i want to display dynamically on each row one button, and dont use datagrid.
2
11954
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put them each in a GroupBox. All the examples I saw from the books or from the web show me how to add static radio buttons at design, or dynamically at run time but with fixed radio buttons (like from an array). I need to create radio buttons based...
7
6783
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al = LoadOracleData(sql) '____Do amazing things
3
4143
by: wayneray | last post by:
Looking for a start on how to accomplish my goal of enhancing our current database. We currently take in data then call that data to web pages to view details using PHP. Since the data is from survey interviews, I want to create tables based on each study name and place all complete survey data pertaining to each study in the applicable table. Then, call data from these tables via PHP. Number of columns varies from study to study. Since...
1
1680
by: ashima515 | last post by:
Hi.. I have made a drop down list...On selecting any of the option i want to display a table. Now the number of rows in the table depends on the selection. I am able to create a table with fixed number of rows.The servlet returns a array of string and i am able to display for fixed number How can i create it dynamically? Pls reply ASAP
3
2071
by: Rambaldi | last post by:
Although i'm working on ASP.net, i think the problem i'm facing is related to my javascript function so i hope i create the thread in the right section. My goal is to create a table dynamically, depending with the number of cameras i got. The code is: var tabela = "<table border=2 width='100%' heigth='100%'><tr>"; var lastCol = 3; for (var i = 1; i <= nCam; i++) {
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
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...
0
8708
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8489
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
8594
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
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
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
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.