Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#814128
Hi,
I am wondering if it is possible to show a field based on the value of one of three other fields.
For example, I have three dropdown fields, namely Country of residence (id= #ctryRes), Country of citizenship 1( id= #ctryCitizen1), and Country of citizenship 2 (id= #ctryCitizen2). If a user selects "United States" (value = US) from one of the three dropdown fields, then another dropdown field called "U.S. State" (id = #USstate) appears.
Appreciate any help or suggestion.
Thanks
#814142
Add this JavaScript to your Dynaform:
Code: Select all
function hideOrShowState(residence, citizen1, citizen2) {
   if (residence == "US" || citizen1 == "US" || citizen2 == "US") {
       $("#USstate").show();
   } else {
       $("#USstate").hide();
   }
}

$("#ctryRes").setOnchange( function(newVal, oldVal) {
    hideOrShowState(newVal, $("#ctryCitizen1").getValue(), $("#ctryCitizen2").getValue());
});
$("#ctryCitizen1").setOnchange( function(newVal, oldVal) {
    hideOrShowState($("#ctryRes").getValue(), newVal, $("#ctryCitizen2").getValue());
});
$("#ctryCitizen2").setOnchange( function(newVal, oldVal) {
    hideOrShowState($("#ctryRes").getValue(),  $("#ctryCitizen1").getValue(), newVal);
});
//When Dynaform loads:
hideOrShowState($("#ctryRes").getValue(),  $("#ctryCitizen1").getValue(), $("#ctryCitizen2").getValue());

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]