Search code examples
javascripthtmldotnetnuke

In DNN, How to combine my .js file or JS Code also with newly created Page


How to add this javascript with my newly created page in DNN?

I tried many ways to add javascript and Jquery but no reflection i found

var CheckedArray = [];

function addPackageDataToList(packageId) {
    if (packageId == '1') {
        var qty = $('#txtPackageQuantity' + packageId).val();
        if (qty != '' && qty != undefined && qty > 0) {
            var obj = {
                PackageName: "Package 1",
                Qty: $('#txtPackageQuantity' + packageId).val(),
                Price: 50
            } 
        } else {
            alert("Please add valid quantity");
        }
    }
}

Solution

  • If you want to add this to a single page, one way to do this is to add it to an HTML module.

    Add the module to the page. Edit and go to HTML mode. Wrap your code in script tags. Save the module.

    Before doing this you will want to make sure that the HTML Editor is NOT configured to strip code from the module. You do this on the Host, HTML Editor Manager page (DNN 8 and below) or Site Settings -> Site Behavior -> More -> Open HTML Manager in DNN 9.x.