...

View Full Version : How can I create a link tag and and assign LoadSupplierProductsGrid to onlick dynami



asifakhtar
03-11-2012, 01:21 AM
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.



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

devnull69
03-11-2012, 09:57 AM
How about that?



"<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


LoadSupplierProductsGrid(ContentOfParameterA, "ContentOfParameterB")

glenngv
03-11-2012, 12:17 PM
Use DOM to create the link and then assign an onclick handler


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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum