473,404 Members | 2,213 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,404 software developers and data experts.

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

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 1040
Rabbit
12,516 Expert Mod 8TB
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
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...
2
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...
1
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...
1
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...
2
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...
7
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...
0
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...
5
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...
1
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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...

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.