dimanche 27 avril 2014

What is best practice for check on radio buttons


Vote count:

0




I'm working on a checkout page which have 2 radio buttons.


Company and Private


Private is checked by default, if click on company it shows a span. But if i reload the browser company will remain checked, but the span is not shown.


How to "combine" all this logic the best way?


i need to "check" on page load which one is checked + i need to check when there's a change to the radio set - can i combine that somehow, so i end up with just one function?



//Check if company is set
if ($("#check-acceptd").is(":checked")) {
$("#Name").hide();
}
else
{
$("#Name").show();
}
});

<span>Private</span>
<input type="radio" checked="checked" name="radioCustomerType" id="radioPrivate" />
<span>Company</span>
<input type="radio" name="radioCustomerType" id="RadioCompany" />

<span id="Name">testing...</span>


asked 30 secs ago






Aucun commentaire:

Enregistrer un commentaire