Solved

jQuery with dynamic id

Posted on 2011-09-12
2
403 Views
Last Modified: 2012-05-12
Hi,

Am trying to get the values of a <td> tag in jQuery function which am not getting it.  Here is the code.  The line which is bold and italic is the point where i need the value of tag <td>:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<%@page import="java.util.List"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Tremor VTQ Page</title>
<style type="text/css">
.even {
      background-color: silver;
}
</style>
<style type="text/css" media="screen">
    .jqplot-axis {
      font-size: 0.85em;
    }
    .jqplot-title {
      font-size: 1.1em;
    }
</style>
<link rel="stylesheet" type="text/css" href="/js/jquery.jqplot.css" />
<script language="javascript" type="text/javascript" src="<c:url value="/js/jquery.js"/>"></script>
<script language="javascript" type="text/javascript" src="<c:url value="/js/jquery.jqplot.js"/>"></script>
<script language="javascript" type="text/javascript" src="<c:url value="/js/jqplot.canvasTextRenderer.min.js"/>"></script>
<script language="javascript" type="text/javascript" src="<c:url value="/js/jqplot.canvasAxisLabelRenderer.min.js"/>"></script>
<script language="javascript" type="text/javascript">
$(document).ready(
            function (){
                  alert('Inside JS.');
                  $.jqplot.config.enablePlugins = true;
                  var nocArr = [];
                  var times = [];                                    
                  for (var i=0;  i<20; i++) {
                        alert(i+' -- '+$("#numOccurences"+i).data());
                      nocArr.push([i, $("div#numOccurences"+i)]);
                    }
                    var plot1 = $.jqplot("chart1", [[nocArr]]);
            });
</script>
</head>
<body>
<div id="mainDiv" title="Main Block" style="border: 1px;border-color: black; background-color: white">
      <table id="mainTab" style="border: thick; border-color: black" cellpadding="5" rules="all">
            <tr id="graphrow">
                  <td>
                        <div id="dataDiv" style="margin-top:20px; margin-left:20px; width:360px; height:600px; overflow: scroll; border: medium" >
                              <c:if test="${fn:length(numOccurrences) > 0}">
                                    <table id = "tableGraph" cellpadding="5">
                                          <thead id="tableheader" valign="top">
                                                <tr class="even">
                                                      <th>Number of Occurrences </th>
                                                      <th>Generated Time </th>
                                                </tr>
                                          </thead>
                                          
                                          <c:forEach items="${numOccurrences}" varStatus="status">
                                          <tr>
                                                <td id="numOccurences${status.index}">${numOccurrences[status.index]}</td>
                                                <td id="timeInterval${status.index}">${timeInterval[status.index]}</td>
                                          </tr>
                                          </c:forEach>
                                    </table>
                              </c:if>
                        </div>
                  </td>
                  <td id ="count" style="width: 1px" title="${fn:length(numOccurrences)}"/>
                  <td>
                        <div id="chart1" style="margin-top:2px; margin-left:20px; width:360px; height:300px;"></div>
                  </td>
            </tr>
      </table>
</div>
</body>
</html>
0
Comment
Question by:lakkarajumurali
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36523468
what about :

$(document).ready(
            function (){
                  alert('Inside JS.');
                  $.jqplot.config.enablePlugins = true;
                  var nocArr = [];
                  var times = [];
$("td:eq(0)","#tableGraph tr").each(function(i, el) {
                        alert(i+' -- '+$(this).text());
                      nocArr.push([i, $("div#numOccurences"+i)]);
})  
                       
                    var plot1 = $.jqplot("chart1", [[nocArr]]);
            });
0
 

Author Comment

by:lakkarajumurali
ID: 36523827
Great it works!! thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to see all occupied ports on windows 10 laptop 15 85
jboss 7.1 start up error 1 64
Javascript Urgent help (Need help to disable event handler) 8 62
Java class and jar 3 43
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

730 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