#115 – Class request

Posted in ‘Easycheckbox’
This is a public ticket. Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
 Hi guys,

I have a question, is it possible and easy to add a class to the selected input field?

Thanks.
Eliel
Hi Eliel,

Do you mean only when page is created or on the go - so when user selects checkbox.

Well, in both case it's possible and not hard to do it.

Open plugins/vmcustom/easycheckbox/easycheckbox.php

If you want to add class by default - so when page is created, find
<input style="float: left; margin-right:5px;"
and add class=SOMECLASS". It's three times in the code.

If you want replace classes on the go, you need to do it with javascript. Find
function setCheckboxJavascript () {
and after
Virtuemart.setproducttype(form, id);
add this:
				jQuery(checkbox).parents(".product-field-display").find("input:checkbox").each(function() {
					if (jQuery(this).prop("checked") == true) jQuery(this).attr("class", "checked");
					else jQuery(this).attr("class", "");
				});
Best Regards,
Maja
maja_mlinar
Hi Maja, actually I was looking both.

I added the javascript. It works great, but when the page loads the class is not added until I clicked again the checkbox.

I'm using #Checked parameter.

Thanks
Eliel
Hi Eliel,

Try this - find
$checked = 'checked';
and replace it with
$checked = 'checked class="checked"';


Best Regards,
Maja
maja_mlinar
Thanks, It worked... is it posible to do the same for the span next to input field?

Eliel

About the author

Who‘s behind this

Demo

Maja Mozina Mlinar

founder
Demo

Sandi Mlinar

procurator

info@sm-planet.net

Skype: maja.mozina1