Show/Hide Form Example

E-mail Print PDF

Download sample form

Show-Hide Other example

Radio example

How did you find us?



Invalid Input
Invalid Input

Dropdown example

How did you find us ?
Invalid Input
Invalid Input


In this article we will describe the steps needed in order to create a Show/Hide Form with RSForm!Pro, radio group implementation. Note: The actual validation is not triggered in the sample form.

  • First you will need to make sure all your fields placeholders are used in the code from the Form Layout tab;
  • You will need to use a custom script that checks if the correct conditions are met and then show the field if they are all met. The show / hide part will be performed by a Javascript code. The script should be similar to:
    	if(document.getElementById('Find3').checked){
    document.getElementById('helement1').style.display="";
    }
    else {
    document.getElementById('helement1').style.display="none";
    document.getElementById('FindOther').value="";
    document.getElementById('component11').setAttribute("class", "formNoError");
    }
  • you can also make the hidden field required if displayed by adding the following script, in the PHP Scripts > Scripts called on form process area:
    if($_POST['form']['Find'] == 'Other' && $_POST['form']['FindOther'] == ''){
    $invalid[] = RSFormProHelper::getComponentId("FindOther");
    }
  • after the script is ready you will need to trigger it when the user makes a selection or fills in a field. This can be done by adding different triggers (onfocus, onclick, onchange...) in the Additional attributes of your form fields, for example:
    		
    onclick="displayField();"
    
  • in order to hide your desired field when the page is loaded you will have to add the following code after your already existing code from the CSS and Javascript:
    window.addEvent('domready', function() {
    displayField1();
    });
    this will trigger the function after the page is loaded and hide the field if the correct conditions are not met.
Last Updated on Wednesday, 18 January 2012 11:21  

RSform!Pro Submission Listing

Ted Smith ted@email.com
John Doe john@email.com
Results 1 - 2 of 2

RSForm! Pro Module

Module Position Sample
First Name

Invalid Input
Last Name

Invalid Input
Email Address (*)

Invalid Input

  


Time till next database reset