Please watch the video of the issue. and review my View Code and JS Code I am using.
hidden link
[credform]
<div class="proto">
[cred_field field='form_messages' class='alert alert-warning']
<label>Datum</label>
[cred_generic_field type='textfield' field='date2' placeholder='Datum auswählen' class='datepick']
{
"required":1,
"default":""
}
[/cred_generic_field]
<label>Durchführende person</label>
[cred_generic_field type='radio' field='assigned_user' class='assignedu']
{
"required":1,
"default":[],
"options":[{"value":"SH","label":"SH"},{"value":"AG","label":"AG"},{"value":"SS","label":"SS"},{"value":"Sabine Stranzl","label":"Sabine Stranzl"},{"value":"Carmen Ungar","label":"Carmen Ungar"},{"value":"Patricia Vicujnik","label":"Patricia Vicujnik"},{"value":"other","label":"Other"}],
"value" : "SH"
}
[/cred_generic_field]
<div id="others">
<label>Durchführende person</label>
[cred_generic_field type='textfield' field='others' placeholder='Max. 30 Zeichen']
{
"required":0,
"default":""
}
[/cred_generic_field]
</div>
<div class="form-group" style="margin-top:10px;">
[cred_field field='form_submit' output='bootstrap' value='Einreichen' class='sbtn-client']
</div>
</div>
[/credform]
jQuery(document).ready(function($) {
$(function () {
$('#others').hide();
$("input[name=assigned_user]:radio").click(function () {
if ($('input[name=assigned_user]:checked').val() == "other") {
$('#others').show();
} else {
$('#others').hide();
}
});
});
});
Hello and thank you for contacting Toolset support.
Because the form will be available for each item of the loop, you should use a class instead of an ID for the section to hide/show:
<div class="others">
<label>Durchführende person</label>
[cred_generic_field type='textfield' field='others' placeholder='Max. 30 Zeichen']
{
"required":0,
"default":""
}
[/cred_generic_field]
</div>
Then you will need to run the Javascript logic(hide the div, and display it based on the radio selection) run for each item of the loop. Not only for the first one. Something like this will do it:
jQuery(document).ready(function($) {
$('.proto').each(function(){
var _this = $(this) // get the loop item's div.proto
var others = _this.find('.others'); // get the section to hide
others.hide();
_this.find("input[name=assigned_user]:radio").click(function () {
if ( _this.find('input[name=assigned_user]:checked').val() == "other") {
others.show();
}else{
others.hide();
}
});
});
});
For your second question on the video(required generic field), change the default value of the field to an empty string "":
However, for support rules, we are able to handle only one issue at a time. This helps us to bring you a better service and also helps other users to find all the information here exposed. So, if it does not help, please create a new ticket for me and ask for me on it and I'll help you with it.