need to handle a table which is produced dynamically

Discussion in 'JavaScript' started by SandeepG14, Aug 29, 2012.

  1. #1
    Hi all....

    Am new to this forum,
    i think this forum is correct for the javascript.
    My question is...
    In my application, in a page there are 2 fields "from date" and "to date" and then a search button. When ever i enter dates and click on search button data gets populated dynamically based on the dates given.If there are no records in DB that satisfy the criteria then ill be displayed a message saying "No records found". Now what my problem is when data gets populated I have to make 1 column data as hyperlink using javascript. But i have only table id nothing more than that.Bcoz table is generated dynamically.So plz give me the code how to handle this problem.
     
    SandeepG14, Aug 29, 2012 IP
  2. KsNitro

    KsNitro Greenhorn

    Messages:
    60
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    20
    #2
    You can use javascript to dynamically create the html content. I can't give you the code since I'm not sure exactly how your page is structured. But it could go something like this:

    1. Write javascript, perhaps using jquery, and get a reference to the table after it has been created. You can use the id to access it with jquery.

    2. Then if necessary query your database using ajax to get the data from the db.

    3. Dynamically add the extra column with the hyperlinks included. Even if the table is dynamically generated, you can still reference it with javascript and add to it.
     
    KsNitro, Aug 29, 2012 IP
  3. SandeepG14

    SandeepG14 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your reply but i dnt want to make use of DB and using javascript i have got the data using table id. Now am trying to make it as a hyperlink.i have written this snippet of code....

    function loadForm()
    {
    var refTab = document.getElementById("ctl00_uxPgCPH_PageDtlsGrid");




    if(refTab != null)
    {
    alert(refTab+' refTab');


    var value = refTab.rows[1].cells[3].innerHTML; (Am getting the data here)


    alert('Data = '+value);


    var attrb = document.getElementsByName(value); (Am trying to get element id)


    alert(attrb); (I got it)

    // now am trying to make that feild as hyperlink but the prob is am getting the error as "Object does not support this property or method..."


    var div = document.createAttribute("href");

    div.nodeValue ="";

    document.getElementsByName(value).setAttributeNode(div);


    }


    }
    May i know y its not allowing to set the attribute????
     
    SandeepG14, Aug 29, 2012 IP