I have 3 radio option fields on product page. I need to show extra input (text field) ONLY if one of them is selected. How to do it?
I think the simplest way will be add another option position (input text) and then add in jQuery simple if/else to show this input only is specific radio is selected. It's only one option that I know. Maybe you know better one? I need this co collect ID card number to add extra TAX. If user select first radio then input text is showing and he must write there his ID card number.
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
I know how to write it, but I asked is there maybe other easiest way to do it in OC

There's no easier way, you need to add a jQuery.magisterson wrote: ↑Tue Oct 22, 2019 4:29 pmI know how to write it, but I asked is there maybe other easiest way to do it in OC![]()
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
Code: Select all
<style>
.idcardnumber{
display:none;
}
</style>
Code: Select all
<script type="text/javascript">
$(document).ready(function() {
$('input[type="radio"]').click(function() {
if($(this).attr('value') == '18') {
$('.idcardnumber').show();
}
else {
$('.pesel').hide();
}
});
});
</script>
I can't figure out how OC makes them required... there is no JS there. no REQUIRED attribute in html code, nothing.
Any ideas how to change them to REQUIRED only if radio is selected?
The actual validation of the input fields is done in the controller.
so in the controller you can add that if the radio selection = x and the input of the field is empty, set the error.
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
Users browsing this forum: paulfeakins and 34 guests