Set field value via URL

Set field value via URL


Parameters can be added in the URLs that direct to form pages. Using these parameters, you can customize your form to automatically add them as default values for its fields. RSContact! comes with a pre-defined function for this scenario, you will just have to follow these steps.

  • Build your form by enabling the form fields.
  • Head over to your frontend, on the page where RSContact! is published and retrieve the field ID's (for the fields you want to populate) with a developer tool such as Firebug
  • In the Module Configuration > Form Options > Custom Javascript textarea, you will have to call the following function:
  •  
    jQuery(document).ready(function(){
      RSContact.setValue('#field_id', 'custom-parameter'); // note that you can use this for all your fields, e.g.
      RSContact.setValue('#field_id_2', 'custom-parameter-2');
      RSContact.setValue('#field_id_3', 'custom-parameter-3');  
    });      
     
  • Let's assume that you have the module published on the first page, in order to populate a field with a value you will have to use this URL :
    /index.php?custom-parameter=John
  • Calling multiple parameters (or if where you are calling it, this is not the first parameter in the URL, you will have to use the "&" symbol) can be done like this:
    /index.php?custom-parameter=John&custom-parameter-2=Doe&custom-parameter-3=Male
Please note that although basic Javascript knowledge would be useful, if you follow the syntax you shouldn't have any problem

One person found this article helpful.


Was this article helpful?

Yes No
Sorry about that

You Should Also Read

Custom RSContact! Parameters

General Joomla! Module Configuration

Emails are not getting sent