Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Feb 2009
    Posts
    121
    Thanks
    7
    Thanked 0 Times in 0 Posts

    How can I create a link tag and and assign LoadSupplierProductsGrid to onlick dynami

    Hi,
    How can I create a link tag and and assign LoadSupplierProductsGrid to its onlick dynamically in javascript?

    My Function should be like the following:
    LoadSupplierProductsGrid(ParameterA, ParameterB)

    I have done it with 1 “ParameterA” but having difficulties creating it with 2 parameters.


    Code:
    "<a href='javascript:void(0);' onclick='LoadSupplierProductsGrid(" + ParameterA + ")'>" + ReportRSet.getfieldbyname(i, "Company Name") + "</a>";

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,390
    Thanks
    11
    Thanked 565 Times in 558 Posts
    How about that?

    Code:
    "<a href='javascript:void(0);' onclick='LoadSupplierProductsGrid(" + ParameterA + ", " + ParameterB + ")'>" + ReportRSet.getfieldbyname(i, "Company Name") + "</a>";
    If that doesn't work you'll have to think about how exactly(!) the resulting code should look like. Depending on the type of the parameter, you can have something like
    Code:
    LoadSupplierProductsGrid(ContentOfParameterA, "ContentOfParameterB")

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,030
    Thanks
    0
    Thanked 247 Times in 244 Posts
    Use DOM to create the link and then assign an onclick handler

    Code:
    var link = document.createElement('a');
    link.href = "#";
    link.innerHTML = ReportRSet.getfieldbyname(i, "Company Name");
    link.paramA = ParameterA;
    link.paramB = ParameterB;
    link.onclick = function() {LoadSupplierProductsGrid(this.paramA, this.paramB); return false;}
    //then append link to its parent
    parentElementHere.appendChild(link);
    I'm assuming that this block of code is inside a loop and ParameterA and B have different values for each iteration.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •