var a = document.createElement('a');
a.appendChild(dynval);
a.href='javascript:void(0)'          
a.onclick=bindme(dynval)
td.appendChild(a)
row.appendChild(td)

function bindme(bval){
temp=bval
return function(){
alert(temp)
}
}

The above code is not complete....

the problem is i am generating dynamic rows inside table's tbody. and i split the rows in to client side pages where each page may display 5 rows. I want to get the values of a cell/row in the rows of these pages. I am getting the values of the cells/rows for the first and last page but not between these pages (ie i'm not getting values of 2 to n-1 pages, u mean the rows are displaying but when clicking on the rows i'm not getting any value)

Kindly help me. i'm pulling my hairs for week

Edited 3 Years Ago by __avd: fixed formatting.

You need to provide us with a 'running and short' example of your code so that we can easily test it out. Just pasting out random snippets won't do you much good.

Also take a look at the generated code for your 'in between' pages and see whether it is the same as the other ones.

You need to provide us with a 'running and short' example of your code so that we can easily test it out. Just pasting out random snippets won't do you much good.

Also take a look at the generated code for your 'in between' pages and see whether it is the same as the other ones.

Thanks for your reply..

I have attached the html file for your reference. please click on the rows of first page and last page. but "in between" page cannot much help.

Thanks for helping me.

Mahir

Attachments
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script type="text/javascript">
    objJSON={
        "Header":[
            {"HeaderName":"CountryCode","Size":"100px","hide":0},
            {"HeaderName":"CountryName","Size":"100px","hide":0},
            {"HeaderName":"Country","Size":"100px","hide":1}
        ],
        "SEARCHFIELD":"1","TEXTFIELD":"1","VALUEFIELD":"0",
        "TABLE":[
                    {
                        "ROW":[ 
                                {"COL":[ {"DATA":"AF"},{"DATA":"AFGHANISTAN"}]}, 
                                {"COL":[ {"DATA":"AL"},{"DATA":"ALBANIA"}]}, 
                                {"COL":[{"DATA":"DZ"},{"DATA":"ALGERIA"}]}, 
                                { "COL":[ {"DATA":"AS"},{"DATA":"AMERICAN SAMOA"}]}, 
                                { "COL":[ {"DATA":"AO"},{"DATA":"ANGOLA"}]}, 
                                { "COL":[ {"DATA":"AI"},{"DATA":"ANGUILLA"}]}, 
                                { "COL":[ {"DATA":"AQ"},{"DATA":"ANTARCTICA"}]}, 
                                { "COL":[ {"DATA":"AG"},{"DATA":"ANTIGUA AND BARBUDA"}]}, 
                                { "COL":[ {"DATA":"AR"},{"DATA":"ARGENTINA"}]},
                                { "COL":[ {"DATA":"AM"},{"DATA":"ARMENIA"}]}, 
                                { "COL":[ {"DATA":"AW"},{"DATA":"ARUBA"}]}, 
                                { "COL":[ {"DATA":"AU"},{"DATA":"AUSTRALIA"}]}, 
                                { "COL":[ {"DATA":"AT"},{"DATA":"AUSTRIA"}]}, 
                                { "COL":[ {"DATA":"AZ"},{"DATA":"AZERBAIJAN"}]} 
                        ]
                    }
            ]
    }
    
    
    function autoCompletePage(divid,page,cSearch){
    d1=Utility.getObj(divid);
    d1.innerHTML="";
    //d1.removeChild();
    ROWS_LENGTH=objJSON.TABLE[0].ROW.length
    //alert(ROWS_LENGTH)
    if(cSearch ){ 
        //alert(arrIndex.length)
        //if(arrIndex!=false){     
       // alert(Filter)
        if(Filter!='')ROWS_LENGTH=arrIndex.length
        //}
        
    }
   // alert("rowslength="+ROWS_LENGTH)
    upper=ROWS_LENGTH>(page*ROWS_TO_DISPLAY)?(page*ROWS_TO_DISPLAY):ROWS_LENGTH;
    lower=(page*ROWS_TO_DISPLAY)-ROWS_TO_DISPLAY;
    l=ROWS_LENGTH;
    m=(l%ROWS_TO_DISPLAY)==0?0:1;
    totalpage=parseInt(l/ROWS_TO_DISPLAY)+parseInt(m);
    table1=Utility.create('table');
    table1.setAttribute('cellpadding','3px');
    table1.setAttribute('cellspacing','0px');
    table1.style.fontSize='11px';
    tbody1=Utility.create('tbody');
    
    for(i=lower;i<upper;i++){
        rows=Utility.create('tr');
        if(i%2==0)
            rows.className=ALTERNATING_ROWS_CLASSNAME
        else
            rows.className=ROWS_CLASSNAME
        
//        if(cSearch){            
//            if(Filter!='') {
//                temp=arrIndex[i]
//            }
//            else temp=i
//        }
//        else temp=i       
       temp=i
        for(k=0;k<objJSON.TABLE[0].ROW[temp].COL.length;k++){
            td1=Utility.create('td');
            try{td1.style.width=objJSON.Header[k].Size}catch(size){};
            
            td1.innerHTML=Utility.data(objJSON,0,temp,k);
            //td1.appendChild(div1);
//            for(m=0;m<hiddenColumn.length;m++){
//                if(hiddenColumn[m]==k)td1.style.display='none'
//            }
            rows.appendChild(td1);
           // rows.onmouseover =mOver(rows)
            //rows.onmouseout = mOut(rows)
        }
       // td1=Utility.create('td');
        //var a = document.createElement('a');
        //a.appendChild(document.createTextNode(Utility.data(objJSON,0,temp,0) ));
       
        oTF=objJSON.TEXTFIELD==""?0:objJSON.TEXTFIELD;
        oVF=objJSON.VALUEFIELD==""?0:objJSON.VALUEFIELD;
        textval=Utility.data(objJSON,0,temp,oTF)
        hdfValue=Utility.data(objJSON,0,temp,oVF)
        
        //a.href='#'
        
       // a.setAttribute('href','javascript:bindme3(hdfValue)'); 
        
       // a.onclick=bindme3(hdfValue)
        //td1.appendChild(a)
       // rows.appendChild(td1);    
        tbody1.appendChild(rows);
       rows.onclick=bindMe(hdfValue,textval,TEXTBOXID);
    }
    
    table1.appendChild(tbody1);
    d1.appendChild(table1);
   // if(upper==1)fn_FirstMatchingRecord(textval,hdfValue)
    footer(divid,page,cSearch)
    //d1.innerHTML=d1.innerHTML+"<br>";
}
function bindme3(h){
            var temp=h;            
            return function(){
                alert(temp)
            }
        }
function bindMe(hiddenValue,TextBoxValue,textboxid){
    var hiddenValue=hdfValue;
    var TextBoxValue=textval;
    var textboxid=TEXTBOXID;
    
   // bindMe2(hdfValue,TextBoxValue,textboxid)
    return function(){
//        alert("jsdf")
//       // d=Utility.container()
////        CLICKED=true;
////        if(hiddenValue!=''){
       alert(TextBoxValue)
////            //Utility.setValue(textboxid,TextBoxValue);
////            //Utility.setValue(HDFID,hiddenValue);            
////        }
//        //create hidden field
//       // Utility.container().style.display='none'
//      

    }
    
}
function bindMe2(){
alert(arguments[0])


}
TEXTBOXID=''
ROWS_CLASSNAME=''   
Utility={}
Utility={
//trim
//   trim:function(str){return str.replace("/^\s*/g|\s*Utility/")},
    getObj:function(obj){return document.getElementById(obj)},
    getValue:function(obj){return this.getObj(obj).value},
    setValue:function(obj,val){this.getObj(obj).value=val},
    container:function(){return this.getObj('autocomplete')},   
    hide:function(obj){return obj.style.display='none'},
    hide:function(){return this.style.display='none'},
    create:function(str){return document.createElement(str)},
    data:function(obj,a,b,c){return obj.TABLE[a].ROW[b].COL[c].DATA},
    noRecords:function(){ADDFIRSTMATCHINGRECORD=false;return "<br><font color='red'><center>No Records for "+Utility.getValue(TEXTBOXID)+"</center></font><br>"}
}
String.prototype.trim=function(){return this.replace("/^\s*/g|\s*Utility/")}
Utility.container.hide=function(){return Utility.container().style.display='none'}
Filter=''
ROWS_TO_DISPLAY=5;
ALTERNATING_ROWS_CLASSNAME='';
MAXRECORDS=500
function footer(divid,page,cSearch){
    d1=Utility.getObj(divid);
    page=page
    if(cSearch && Filter!='')
        
        ROWS_LENGTH=(arrIndex!=false)?arrIndex.length:0;
    else
        ROWS_LENGTH=objJSON.TABLE[0].ROW.length
    //alert(ROWS_LENGTH)
    //ROWS_LENGTH=objJSON.TABLE[0].ROW.length
    
    upper=ROWS_LENGTH>(page*ROWS_TO_DISPLAY)?(page*ROWS_TO_DISPLAY):ROWS_LENGTH;
    lower=(page*ROWS_TO_DISPLAY)-ROWS_TO_DISPLAY;
    l=ROWS_LENGTH;
    m=(l%ROWS_TO_DISPLAY)==0?0:1;
    c=Utility.create('span');
    
    if(l>1)c.innerHTML="page:"+page+"/"+totalpage;
    d1.appendChild(c);
    
    if(page>1){
        c=Utility.create("span");
        prev=page-1;
        c.innerHTML="<a href=\"javascript:void(0)\" onclick=\"autoCompletePage('"+divid+"',"+prev+","+cSearch+")\">Previous</a>";
        d1.appendChild(c);
    }
    
    nextpage=ROWS_LENGTH>(page*ROWS_TO_DISPLAY)?(parseInt(page)+1):page;
    
    if(nextpage>page && page>1) d1.innerHTML=d1.innerHTML+"&nbsp;|&nbsp;";
    if(nextpage>page){
        c=Utility.create("span");
        c.innerHTML="<a href=\"javascript:void(0)\" onclick=\"autoCompletePage('"+divid+"',"+nextpage+","+cSearch+")\">Next</a> | ";
        d1.appendChild(c);
    }
    c=Utility.create("span");
    c.innerHTML="Max Records to display:"+MAXRECORDS;
    d1.appendChild(c);
    //d1.appendChild(d2)
   // footer1(d1)
}
    </script>
</head>
<body>
<div id="temp1">dfgsd</div>
<div id="autocomplete"></div>
<script type="text/javascript">
autoCompletePage('temp1',1,true)
</script>
</body>
</html>
This article has been dead for over six months. Start a new discussion instead.