开发者

Jquery Load onclick data driven customisation system

开发者 https://www.devze.com 2023-01-27 03:03 出处:网络
This code is to work in combination with a form showing the results of the selections made on the right hand side of the page by loading the URL of the chosen option in a specified DIV that correspond

This code is to work in combination with a form showing the results of the selections made on the right hand side of the page by loading the URL of the chosen option in a specified DIV that corresponds to the ID of the prod开发者_JAVA百科uct.

function product_analysis(productid, address) { if (this.checked = 'checked') {

$(productid).load(address);

}
else {

$(productid).load('http://www.divethegap.com/update/blank.html');

}

};

Problem is that the query to check if the box is checked or not does not work. If you check or uncheck the box it loads the address of the onclick event.

Any help would be appreciated but please keep in mind that the products are data driven so we cannot have specific IDs but rather IDs built of the Post ID.

Also when the page loads there will need to be some sort of global function which will work out what is 'checked' and load those URLs (products) in their specific DIVs.

Many Thanks,


Beware that you used = instead of == in the if() condition.

Also, have you tried with the :checked selector?

$("#id:checked")

JQuery documentation


function product_analysis(productid, address, box) {
    if (box.checked) {

    $(#productid).load(address);

    }
    else {

    $(#productid).load('http://www.divethegap.com/update/blank.html');

    }
};

and code for the box

onclick="product_analysis('#product_1231', 'http://www.divethegap.com/update/products/2010/11/padi-open-water/', this)"
0

精彩评论

暂无评论...
验证码 换一张
取 消