Solved

How do I grab textbox value from innerHTML of table cell?

Posted on 2010-11-10
7
1,788 Views
Last Modified: 2012-05-10
I need to get the value of a textbox in each row that I loop through in a radgrid using javascript.  Here is the code to grab the cell which works fine.

var masterTable = $find("<%=gvLines.ClientID%>").get_masterTableView();
var cell;

for (var row = 0; row < masterTable.get_dataItems().length; row++)
{
     cell = masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[row], "Amount").innerHTML;
     alert(cell);
}  

The alert box value is:  <INPUT id="textboxid" class="textbox" value="$52.8: type="text" name="Amount">

How can I grab the value $52.8?

Thanks.
0
Comment
Question by:NOVBusApps
  • 4
  • 3
7 Comments
 
LVL 7

Expert Comment

by:dxdinh
ID: 34107941
try this
 alert (cell.getElementsByTagName("input")[0] );
0
 
LVL 7

Expert Comment

by:dxdinh
ID: 34107946
I mean the value ....

 alert (  cell.getElementsByTagName("input")[0].value );
0
 

Author Comment

by:NOVBusApps
ID: 34108626
I'm getting the "Microsoft JScript runtime error: Object doesn't support this property or method" error.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 7

Expert Comment

by:dxdinh
ID: 34109014
/// I mean this

for (var row = 0; row < masterTable.get_dataItems().length; row++)
{
 alert (  cell.getElementsByTagName("input")[0].value );
}  
0
 

Author Comment

by:NOVBusApps
ID: 34115477
Current code:

 var masterTable = $find("<%=gvLines.ClientID%>").get_masterTableView();
 var cell;
 for (var row = 0; row < masterTable.get_dataItems().length; row++) {
       cell = masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[row], "Amount").innerHTML;          
       alert(cell.getElementsByTagName("input")[0].value);    <---this line throwing same javacript error

 }
0
 
LVL 7

Accepted Solution

by:
dxdinh earned 250 total points
ID: 34117091
-- oh sorry - can you try this

 var masterTable = $find("<%=gvLines.ClientID%>").get_masterTableView();
 var cell;
 for (var row = 0; row < masterTable.get_dataItems().length; row++) {

       // get the cell with the textbox
       cell = masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[row], "Amount");          

      // now get the value by tag name
       alert(cell.getElementsByTagName("input")[0].value);  


 }

0
 

Author Closing Comment

by:NOVBusApps
ID: 34123857
thanks!
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question