Click here to Skip to main content
13,196,126 members (54,086 online)
Rate this:
Please Sign up or sign in to vote.
Hi all...
How should we identify or find value of a control when there are many controls in javascript?
How should identify value of a row entries in table in javascript?
I'm working on MVC3. In my project I have used an action link on which i'm showing modal popup. In that pop up i'm getting data of multiple users(eg. jack,sachin) in table like structure.
Now on my view I've textboxfor(with id="txtOne") and i used an action link(with url text string "select" for each user at the end of row like we do have for edit/delete in grid view at the end). now whenever i select a user his first name should appear in text box. So what to do for this.
How should we identify or find value of a control in javascript?
Thanks in advance...
Posted 31-Aug-12 2:21am
Updated 2-Sep-12 20:40pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I used table row click functon like below:
<script type="text/javascript"><!--
function getVal(e) {
    var targ;
    if (!e) var e = window.event;
    if ( targ =;
    else if (e.srcElement) targ = e.srcElement;
    if (targ.nodeType == 3) // defeat Safari bug
        targ = targ.parentNode;
onload = function() {
    var t = document.getElementById("main").getElementsByTagName("td");
    for ( var i = 0; i < t.length; i++ )
        t[i].onclick = getVal;
<style type="text/css">
#main td {
    border: 1px solid gray;
<table id="main"><tr>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171019.1 | Last Updated 3 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100