473,624 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I retrieve values from combos dynamically added to html table

37 New Member
I have a table with 10 rows added by looping throw a $result from a database query. When the user selects an option from one of the combos, how do I get its value. I have used Javascript but I can only get it to work with the first combo.

COMBO CODE
Expand|Select|Wrap|Line Numbers
  1. echo"<td><select name='status[]' id='combo' onchange='getComboValue()'>";
  2.         echo"<option value='' ". (($row['finished']) == 0 ? "selected='selected'":"") . " >Fixture</option>";
  3.         echo"<option value='' ". (($row['finished']) == 1 ? "selected='selected'":"") . " >Live</option>";
  4.         echo"<option value='' ". (($row['finished']) == 2 ? "selected='selected'":"") . " >Result</option>";
  5.         echo"</select></td>";
  6.  
JAVASCRIPT
Expand|Select|Wrap|Line Numbers
  1. function getComboValue()
  2. {
  3.     var combo = document.getElementById("combo");
  4.     var selectedText = combo.options[combo.selectedIndex].text;
  5.     document.getElementById("hiddenStatus").value = selectedText;    
  6. }
  7.  
  8.  
Apr 22 '14 #1
1 1053
Rabbit
12,516 Recognized Expert Moderator MVP
You said you got it to work with the first combo. Implying that there was at least one other combo. But your code only shows one combo. And it's the combo that works. So I don't know what your question is.
Apr 22 '14 #2

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

Similar topics

3
2671
by: eSapient | last post by:
I created a web page which contains a form which contains a table. The number of rows for the table are determined dynamically. The first cell of each row contains a HyperLink control and the last cell contains a CheckBox control. In order for the ViewState mechanism to work correctly, I: 1. create the structure (add rows/columns) of the table in the OnInit handler when it is a PostBack, 2. create the table structure and populate its...
2
2415
by: buran | last post by:
Dear ASP.NET Programmers, I have a HTML table (running as server control with the control ID: tblInsertSP). The table has 16 rows with textboxes. Depending on the value of the ddlSPType, which is a dropdownlist control on the page, I add dynamically extra rows to the table. For instance, if the ddlSPType selected item is Aviation Company, an extra row containing a cell with the textbox control txtAircrafts is added to the HTML table...
1
1685
by: Jeff H. | last post by:
I created a survey page with dynamically added html controls, as below. However, now that I have the page, is there a way to reference the fields to get the data out? while (drResultList.Read()) { ... // Survey question text System.Web.UI.HtmlControls.HtmlGenericControl hQuestion = new
1
1283
by: dotnettester | last post by:
Hi, I have added some textbox dynamically and now trying to retrieve the values posted on a 'save' event. when I try the following lines I get 'Object reference not set to an instance of an object.....' foreach(Control c in Parent.Controls) <--- line where I'm getting this {
2
920
by: dotnettester | last post by:
Hi, I added a few link buttons in a function (loadControls) that is called only on the first time the page is loaded. On the postBack I don't call this function and want to retrieve the values of those controls (linkButtons). But the only time I can see the values is if call the (loadControls ) on postBack too. How can I get the values of the controls without calling the 'loadControls' function.
7
21475
gchq
by: gchq | last post by:
Hi there Here is the situation - a table is built dynamically with values in the cells I need to retrieve and enter into a database. I have found a way of getting values using JavaScript, but of course with the table being dynamic I have no idea how many rows it will contain. One way is using the TableID.rows.count and then building if statements based on the value - but that is going to be an awfull lot of coding...... So the question is -...
0
1132
by: jburnage | last post by:
I need help in getting the values from a dynamically added user control when a user submits a form. The controls are added to a placeholder and this all works fine - but its looping through the controls that i'm having trouble with. Its the "case 1:" statement that i need help with cheers in advance for any help my code is as follows. // a Property that manages a counter stored in ViewState protected int NumberOfSchemeControls
5
4448
by: Nathan Sokalski | last post by:
I have a custom control that I wrote (I inherit from System.Web.UI.WebControls.CompositeControl). I dynamically add this control to my Page, but I was told that dynamically added controls do not survive postback. This seems to be true. However, this seems to make dynamically adding controls rather pointless to me, since if you cannot retrieve the values of the controls when you perform a postback, why add the controls in the firstplace?...
1
7926
by: terminul | last post by:
Hi I have a datalist which loops through the categories and within the datalist I have a CheckBoxList which are bound on the DataList's OnItemDataBound. The only problem I have is retrieving the values that have been checked when the user submits the form. This code works as far as presentation goes but I can't seem to retrieve the checked values in the various checkboxlists that have been generated on the datalist's OnItemDataBound ...
0
8173
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
8679
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
8335
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
8475
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
7159
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
4079
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
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2606
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
2
1482
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.