The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Change Values Of Multiple Text Fields Based On A Dropdown Selection


This Discussion is public


Here is a function that allows you to change multiple values in text fields either for calculations or strings,Had a developer create a function so here it is if anyone else needs to use it but will need to amend it for their very own field keys and ID'sThe below script needs to be called below the form shortcode or in the footerfield_jflq5 is the key of the dropdown select//change to your very ownfield_j22cx, field_vnlzo, field_owozg are the 3 text fields that change the value from 0 to 1 depending on the selection of the dropdown.//again change to your own fieldsFor example my team results if you would like to populate the fields based on Home Win, Draw , Away Win ( or whatever you want in your own form )Then you can set the values to change, i am wanting to show the value of 1 to the selected dropdown option or else set the value to 0.//add the following code below the form shortcode or in the footer, change the field keys to your ownvar ids=document.getElementById('field_jflq5');ids.setAttribute("onchange","myselect(this.value,'field_j22cx','field_vnlz0','field_owozg')");Here is the function:function changesel(value){alert(value);}var $=jQuery;function myselect(val='1',idinput_1='1',idinput_2='1',idinput_3='1'){console.log(val+'-'+idinput_1+'-'+idinput_3);if(val=='1'){console.log('not real name given');return;//end}var val1 = val;console.log(val1);if (val1 == 'Home Win'){$("#"+idinput_1).val('1');$("#"+idinput_2).val('0');$("#"+idinput_3).val('0');}else if (val1 == 'Draw'){$("#"+idinput_1).val('0');$("#"+idinput_2).val('1');$("#"+idinput_3).val('0');}else if (val1 == 'Away Win'){$("#"+idinput_3).val('1');$("#"+idinput_1).val('0');$("#"+idinput_2).val('0');}}//end myselect fuctionmyselect(); Enjoy

Here is more code for when you want to use the above script in a repeatable section.

function multipleinput(id,value){
//data-sectionid siblings
var section=$('#'+id).attr('data-sectionid');
var txt=$('#'+id+' option:selected').html();

var idparent=$('#'+id).parent().parent().attr('id');
$('#'+idparent+' input[data-sectionid="'+section+'"][data-frmval="0"]').each(function(idx, ele){
var sib=$(this).siblings(':first').html();
sib=sib.replace('<span class="frm_required"></span>','');
sib=sib.replace(' Count','');

var $=jQuery;
function scorecast_result(val='1',idinput_1='1',idinput_2='1',idinput_3='1'){
console.log('not real name given');
var val1 = val;

if (val1 == '')
else if (val1 == '0-0')


Call the function

$(document).on('change', 'select[id^="field_y4g01-"]',function(){multipleinput($(this).attr('id'),$(this).val())});

Discussion closed.