473,783 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic table using javascript

45 New Member
hi everyone,

i am creating dynamic row in a table using javascript its working fine and now i want to create more than 1 table using javascript which is dynamic its also working fine but when i am taking the value of each table individually thats i am not able to get any value. if i get the value of table then its not taking properly.

let me explain the whole scenario...

i want to add product specification . it may vary in number of specification.i .e. i may be 2 or 10 or 30 etc.for each specification i have to add properties it is possible only using dynamic rows.like suppose if i have 5 specification and i have to add properties for each specification then i will use dynamic row creation. And now i am able to do this till now after that i am not able to take the value of all the text fields in a single text field by comma(,) separated.

how will i do this please help me out its urgent...
Apr 8 '09 #1
3 4855
acoder
16,027 Recognized Expert Moderator MVP
Please post your code, so we can see where the problem might lie.
Apr 8 '09 #2
tokcy
45 New Member
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3.      <head>
  4.           <title>Dymanic Row</title>
  5. <script language="Javascript" type="text/javascript">
  6.      function addRow(str)
  7.      {
  8.           var tbl = document.getElementById('mySampleTable'+str);
  9.           var lastRow = tbl.rows.length;
  10.           var iteration = lastRow;
  11.           var row = tbl.insertRow(lastRow);
  12.           var cellLeft = row.insertCell(0);
  13.           var textNode = document.createTextNode(iteration);
  14.           //cellLeft.appendChild(textNode);
  15.           var cellRight = row.insertCell(1);
  16.           var el = document.createElement('input');
  17.           el.type = 'text';
  18.           el.name = 'txtRow' + iteration;
  19.           el.id = 'txtRow' + iteration;
  20.           el.size = 40;
  21.           cellRight.appendChild(el);
  22.           //el.setAttribute("onBlur","setvalue(this);");
  23.      }
  24.  
  25.      function removeRow(str1)
  26.      {
  27.           var tbl = document.getElementById('mySampleTable'+str1);
  28.           var lastRow = tbl.rows.length;
  29.           if (lastRow > 2) tbl.deleteRow(lastRow - 1);
  30.      }
  31.  
  32. function setvalue(str2)
  33. {
  34.     alert(str2);
  35.     var i=0;
  36.     var idstr="txtRow" + str2;
  37.     //alert('item' + str2);
  38.     document.getElementById('item' + str2).value="";
  39.     while(document.getElementById(idstr))
  40.     {
  41.     document.getElementById('item' + str2).value=document.getElementById('item' + str2).value + ',' + document.getElementById(idstr).value;
  42.     idstr='txtRow' + str2;
  43.     str2++;
  44.     }
  45. }
  46. </script>
  47.      </head>
  48.      <body leftmargin="0" topmargin="0">
  49.           <form action="#" name="frm" method="post">
  50.               <? 
  51.               $i=1;
  52.               for($i=1;$i<=5;$i++)
  53.                 {
  54.               ?>
  55.                <table align="center" width = "75%">
  56.                      <tr>
  57.                        <td align = "center">
  58.                  <input type="text" name="item<?=$i?>" id="item<?=$i?>" value="<?=$i?>" size="40" />
  59.                  <table border="1" id="mySampleTable<?=$i?>">
  60.                                      <tr>
  61.                                         <td>&nbsp;</td>
  62.                                         <td>
  63.                                              Specification
  64.                                         </td>
  65.                                         <td>&nbsp;</td>
  66.                                    </tr>
  67.  
  68.                                    <tr>
  69.                                         <td>&nbsp;</td>
  70.                                         <td>
  71.                                              <input type="text" name="txtRow<?=$i?>" id="txtRow<?=$i?>" size="40" value="<?=$i?>" onBlur="setvalue(this);" /></td>
  72.                                         <td>&nbsp;</td>
  73.                                    </tr>
  74.                               </table>
  75.                               <input type="button" name="add" id="add" value="Add" onClick="addRow('<?=$i?>'); setvalue(<?=$i?>);" />
  76.                               <input type="button" value="Remove" onClick="removeRow('<?=$i?>');" />
  77.                               <input type="submit" value="Submit" onClick="setvalue(<?=$i?>);" />
  78.                          </td>
  79.                     </tr>
  80.                </table>
  81.                <?
  82.                }
  83.                ?>
  84.           </form>
  85.      </body>
  86. </html>
  87.  
Apr 8 '09 #3
acoder
16,027 Recognized Expert Moderator MVP
You're passing 'this' to setvalue when you probably mean to pass a string.
Apr 8 '09 #4

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

Similar topics

5
3385
by: Travis Pupkin | last post by:
Hey, I've done a number of product catalogs/galleries with one or two category levels (Category > Subcategory). The straightforward way to do this, of course, is to use database fields for Category and Subcategory and query off of those fields. I have a client now who is interested in what sounds to me to be an unnecessarily complex catalog with an as of yet undefined number of category levels at their disposal.
1
3370
by: OM | last post by:
I am trying to present tree-structure information using a html table and JavaScript. Each tree node is displayed in the first column in a table row. The tree node can also have additional information in other table columns. To make the collapse / expand functionality I want to use JavaScript to display / hide table rows using row.style.display = "inline" / "none". To get references to the table rows they all need unique id's. I want
18
30591
by: chimalus | last post by:
I am using a table with no column widths specified, letting the table layout manager do its thing for figuring out the column widths, and this works just fine. Now I want to make the table dynamic. I have added a filtering mechanism (in javascript) that can be used to hide unneeded rows. However, each time I hide or show rows, the column sizes change, and this doesn't look good. Is there a way that I can preserve the column widths...
1
5532
by: nsvmani | last post by:
Hi, i am trying to get the FileOpen dialogue window as soon as clicked href link I am using IE6 with ActiveX enabled. Just need to get the File Open dialogue window when i click on the HREF links.It would be great , if i know how to create the dynamic HREF links like it should be getting different document based on each userid. Here is my part of jsp code for your reference: <%@ page...
9
2986
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I got the core of the javascript from here: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm I noticed in the demo that sometimes the content takes a long
0
3396
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options within options. I have everything being dynamically named from the previously dynamically named element. (I hope this makes sense.) I am not able to retrieve any of the dynamically created values. I can view them on the source page but can't pull them...
3
4223
by: azegurb | last post by:
hi I have just took from internet dinamic table. this table is dynamic and its rows dynamically can be increased. but i would like how create SUM function that automatically sums each added row value (text value) here is the code if possible please help me Thanks beforehand <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
2
3330
by: yomadhu | last post by:
I created a dynamic form in javascript. Am unable to get those values in to php to display. I need all details. If i add 10 rows the i need to display those all values. Can any one help me for that code. <HTML> <HEAD> <TITLE> Add/Remove dynamic rows in HTML table </TITLE> <script type="text/javascript" src="script.js"> // JavaScript Document var c=0;
0
9643
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
9480
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
10315
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
10147
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
10083
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,...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
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
5379
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...
2
3645
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.