0

I have a table rendered from the values which is fetched from the backend as json,

In one of the cells i have a button on click of this button i would like to render another xhtml page but i also want a parameter to be passed along with the hyperlink how can this be acheived, Thanks in advance herewith i m posting my code for reference,

 $.get('../Paid_deep_dive', {type: "paid_performance", campaign_id: $campaign, s_date: start_date, e_date: end_date}, function (response) {

        var data = response.paid_performance;
        response_data = response;

        $('table#tb2 TBODY').append('<tr><td width ="12%"><form><input type="button" class="btn btn-block btn-lg btn-inverse" onclick="loadtable2(' + elem.site_id + ')" value="' + elem.site_name + '" style="width:100%"  ></form></td>' + elem.site_name + '</center></td><td align="center" width="33%"><center>' + elem.impressions.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td><td align="center" width="25%"><center>' + elem.ontarper + '%</center></td>;<td align="center"><center>' + elem.viewable_imp.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td></tr>');
});

Here in this above code i would like to have an hyperlink at the

onclick = "http://localhost:8080/Digiview_v2/faces/xhtml_files/paid_drill_down.xhtml?variable=" + parameter; 

as well as passing the parameter. is there any way to do it correctly

Barmar
  • 741,623
  • 53
  • 500
  • 612
user2860954
  • 177
  • 2
  • 24

1 Answers1

2

You redirect in JS by assigning to window.location.href:

$('table#tb2 TBODY').append('<tr><td width ="12%"><form><input type="button" class="btn btn-block btn-lg btn-inverse" onclick="window.location.href=\'http://localhost:8080/Digiview_v2/faces/xhtml_files/paid_drill_down.xhtml?variable=' + encodeURIComponent(parameter) + '\'" value="' + elem.site_name + '" style="width:100%"  ></form></td>' + elem.site_name + '</center></td><td align="center" width="33%"><center>' + elem.impressions.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td><td align="center" width="25%"><center>' + elem.ontarper + '%</center></td>;<td align="center"><center>' + elem.viewable_imp.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td></tr>');
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Thanks it works now :) can u also tell me the way to access this passed parameter in the next page? will request.getParameter(parameter) suffice? – user2860954 Mar 03 '15 at 05:52
  • See http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript – Barmar Mar 03 '15 at 05:54
  • That's how to do it in Javascript. If it's in a server-side language, I'm sure there are plenty of tutorials that say how to get URL parameters in that language. – Barmar Mar 03 '15 at 05:55
  • Thanks once again yes its only in javascript so that would suffice i guess, – user2860954 Mar 03 '15 at 05:57