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.
#813744
2018-03-21 16_29_38-PMDynaform.png
2018-03-21 16_29_38-PMDynaform.png (8.29 KiB) Viewed 2487 times
I have this form which has a drop down list of business names. The possibilities are:
1) User will have a business name in the list
2) User doesn't have a business name in the list but has an alternative business name. He will then check "My business name/trading name is not listed" and type it into a hidden field
3) User doesn't have a business name at all and checks the "I don't have a business trading name"

Both checkboxes disable the "choose business name" drop down list validation, but I realized the user can choose both checkboxes and mess up the validation. (currently, it does mess it up if I validate it several times, the form ends up not responding when the submit button is clicked - no error nada)

Can you please help me with the code? my tests show that it is the "I don't have a business name/trading name" causing the form submission problem and it may be due to the clash of enabling/disabling validation on the drop down list being the issue. I don't really want to use radio buttons either because of possibility no.1 and user cannot clear the radio selection.
Code: Select all
//Show/hide Other Trading Name
$('#BusinessNameAlternative').hide();

$("#BusinessNameNotListed").setOnchange( function(newVal, oldVal) {
   //check for version 3.0.1.8 or version 3.1+
   if (newVal == '"1"' || newVal == '["1"]') {
    $('#BusinessNameAlternative').show();
    $('#BusinessNameAlternative').getControl().css({"border": "#FF8C00 solid 1px"});
    $('#BusinessNameAlternative').enableValidation();
    $('#BusinessNameDropDown').disableValidation();
   }
   else {
    $('#BusinessNameAlternative').hide();
    $('#BusinessNameAlternative').disableValidation();
    $('#BusinessNameDropDown').enableValidation();
   }
} );

//If no business name, disable validation on business name drop down
$("#NoBusinessName").setOnchange( function(newVal1, oldVal1) {
  //if value has "1" in it
   if (newVal1 == '"1"' || newVal1 == '["1"]'){
    $('#BusinessNameDropDown').disableValidation();
  }
  else {
    $('#BusinessNameDropDown').enableValidation();
  }
});

Thanks
#813750
I can't tell you why submitting would fail. Do you see any error messages in the web browser debugger when you click on a submit button? In your [ur=http://wiki.processmaker.com/3.2/Config ... Settings:l]env.ini[/url] file, set:
Code: Select all
debug = 1
and then check the error log in workflow/public_html/php_errors.log.

One way to get around the problem is to not make the fields required, but add a submit event handler to check whether your BusinessNameAlternative field is filled if BusinessNameNotListed is checked:
Code: Select all
form = getFormById( $("form").id );
form.setOnSubmit( function() {
   if  ($("#BusinessNameNotListed").getValue() == "0") {
     if ($("#BusinessNameDropDown").getValue() == "") {
       alert("Please select the Business Name.");
       return false;
     }
   } else {
     if ($("#BusinessNameAlternative") == "") {
        alert("Please enter the Alternative Business Name");
        return false;
     }
   }
}); 
#814500
Thanks Amos, I got it to work by modifying your code to my working. Just want to say your support in the community is top notch and our company is leaning towards upgrading to the enterprise version because we can see so much possibilities with ProcessMaker.
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]