Solved

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

Posted on 2010-11-10
7
1,778 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
Comment Utility
try this
 alert (cell.getElementsByTagName("input")[0] );
0
 
LVL 7

Expert Comment

by:dxdinh
Comment Utility
I mean the value ....

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

Author Comment

by:NOVBusApps
Comment Utility
I'm getting the "Microsoft JScript runtime error: Object doesn't support this property or method" error.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 7

Expert Comment

by:dxdinh
Comment Utility
/// I mean this

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

Author Comment

by:NOVBusApps
Comment Utility
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
Comment Utility
-- 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
Comment Utility
thanks!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

762 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

12 Experts available now in Live!

Get 1:1 Help Now