Pregunta

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.

¿Fue útil?

Solución

A jQuery solution:

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

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top