0

I have a html table as below

 <table id="searchResults" class="compact-table" width="100%">
 <thead>
    <th><label id="Revenue"></label></th>
    <th></th>
 </thead>

I am naming the column headers as shown in the code but I want those column names to assign dynamically

I have placed a label named Revenue for that label I am assigning value using Jquery as below

var yearVal = $("#salesDashboardYearDropDown").val();
var monthVal = $('select#salesDashboardMonthDropDown :selected').text();
var revenueLastYear = (monthVal + ' ' + (yearVal - 1).toString()).toString();
$('#Revenue').html(revenueLastYear);

but it is not getting displayedenter code here

3
  • it is a drop down there is no problem withj that I am getting the required value into revenue last year variable but i am unable to assign it to label Commented Jun 4, 2013 at 8:17
  • Can you just provide it anyway or give us a jsFiddle showing the problem. Commented Jun 4, 2013 at 8:18
  • Maybe you have more than one element with id="Revenue"? Commented Jun 4, 2013 at 8:19

1 Answer 1

1

Check that you have used id in your selectelements likesalesDashboardMonthDropDown andsalesDashboardMonthDropDown` with no spacces

I have tried this and it works,

$(function(){
    $("#salesDashboardYearDropDown, #salesDashboardMonthDropDown").on('change',function(){
        var yearVal = $("#salesDashboardYearDropDown").val();
        var monthVal = $('#salesDashboardMonthDropDown  :selected').text();
        var revenueLastYear = (monthVal + ' ' + (yearVal - 1).toString()).toString();
        $('#Revenue').html(revenueLastYear);
    });
});

Also check you have added any version of jquery

Fiddle http://jsfiddle.net/ZmuSL/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.