Solved

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

Posted on 2010-11-10
7
1,782 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now