:: Forum >> Version 2 >>

hyperlink and javascript in a cell

I like the ActiveWidgets. It is a very nice tool and I am investigating whether to buy it or not. Therefore I am analyzing the possibilities of this widget.

A critical decision point is whether I am able to create an image per cell and depending on a javascript confirmation I can go to a url. It is easier to describe using an example:

The widget contains a list of users. In the last column(s) there are a few options, like edit and delete (both with an image). When I click the delete-image, i want javascript confirmation (Are you sure you want to delete this user?) and - if confirmed - an url, like users.php?function=delete&userId=55.

I am able to get the images in the cells that i want, but i am unable to deal with the links/javascript.

I got it working in Firefox, but not in Internet Explorer. Any help?
obj.setCellModel(table);
    
obj.setCellTemplate(new AW.Templates.ImageText);
    
obj.setCellImage("deleteImage"7);
    
obj.setCellLink("javascript:void(7);"7); 
    
obj.setCellTemplate(new AW.Templates.Link7);    // and template 
    
obj.onCellClicked = function(eventcolrow)
    {
        if (
col==7)
        {
            if (
confirm('Are u sure you want to delete 'this.getCellText(3row) + ' 'this.getCellText(2row) + ' from the system?'))
            {

                
strLink "users.php?function=testToDelete&userId="+this.getCellText(0row);
                
window.location.href=strLink;
            }
        }
    };  
    
//    write grid html to the page
    
document.write(obj);
 
Joshua Kroeze
Tuesday, July 11, 2006
Problem solved: This is working both in IE and Firefox.

col 2 + 3 contains lastName,firstName
col 0 contains userId
col 7 contains delete-image
function confirmDelete(elem,link)
    {
        if(
confirm('Are you sure you want to delete '+elem+' ?'))
        {
            
window.location.href=link;
        }
    }

    
//    assign external 'data model'
    
obj.setCellModel(table);
    
obj.setCellTemplate(new AW.Templates.Link6);
    
obj.setCellTemplate(new AW.Templates.ImageText);
    
obj.setCellImage("deleteImage"7);
    
    
obj.setCellLink(function(cr){ return "javascript: confirmDelete('"+this.getCellText(3,r)+' '+this.getCellText(2,r)+"','user.php?function=delete&userId="+this.getCellText(0,r)+"')"; }, 7); 
    
obj.setCellTemplate(new AW.Templates.Link7);    // and template 
 
Joshua Kroeze
Tuesday, July 11, 2006



This topic is archived.

Back to support forum

Forum search