The label text of a checkbox is dynamically generated in CodeCharge. The label text includes the amount of available articles. When this number is (0), the checkbox and the label text should be hidden, if not both checkbox and label value must be shown.

In this case checkbox and label text hidden:

<input id="i_search_2_newdatad9_1" name="d9[]" value="standplaatsreis" type="checkbox"  /><label for="i_search_2_newdatad9_1">Standplaatsreis (0)</label>

In this case checkbox and label visible:

<input id="i_search_2_newdatad9_1" name="d9[]" value="standplaatsreis" type="checkbox"  /><label for="i_search_2_newdatad9_1">Standplaatsreis (8)</label>

I appreciate your suggestions for a php or jquery script.

有帮助吗?

解决方案

A jQuery solution:

$('label:contains("(0)")').each(function() {
    $('#' + $(this).attr('for')).hide();
    $(this).hide();
});

其他提示

Since you mention jQuery in your question:

$(function() {
   $('input').filter(function() { return $(this).next('label').text().substr(-3) == '(0)'; }).hide().next('label').hide();
   });
});

A PHP solution would be better, but without any code, we cannot help you.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top