Forums

How to pre populate a form from URL Parameters

almartin2 21 Oct, 2009
I'm trying to pre-populate 2 fields on a form from a set of URL Parameters - they are set as hidden fields so do not need to be entered by the user.

The idea is that we provide a link to our customers via email, the simply click on it, fill in the rest of the form and then submit it to us, but it means they do not need to remember their client number or a case reference number

This is what our URL would look like:

http://www.mydomain.com/index.php?option=com_chronocontact&chronoformname=ClientSurvey&CLINO=33359&CASENO=56333

What code do I need to put into our form so that it will read the parameters from the URL and place these into the hidden fields when the user clicks on Submit?

Many thanks
GreyHead 21 Oct, 2009
Hi almartin2,

You can't easily (I guess you could with some JavaScript) but you can pick them up after the for is submitted.
<?php
$CLINO = JRequest::getVar('CLINO', '', 'get');
$CASENO = JRequest::getVar('CASENO', '', 'get');
?>

Bob
almartin2 28 Oct, 2009
Hi Bob,

Thanks for the response, and sorry for the delay in mine, it's something I want to be able to do as part of the form submission process and make sure it's attached to the confirmation email I send out. If this could be done with Javascript, does anyone have any examples of how it might be done?


Many thanks
Anthony
GreyHead 28 Oct, 2009
Hi Anthony,

Reading this again I think I was wrong - try using the code I posted in the Form HTML it shoudl be OK.

Bob
almartin2 28 Oct, 2009
Hi Bob,

Have just copied the code into the HTML element of the form in the ChronoForms admin panel for this form and have tried again but still cannot seem to get it to pull the values forward into the form and then populate these in the email sent when the form is submitted.

Should there be any additional javascript code in the form submission section to make this work??

Thanks
GreyHead 28 Oct, 2009
Hi Anthony,

The code to get a parameter from the calling URL into a hidden field is this:
<?php
$CLINO = JRequest::getVar('CLINO', '', 'get');
?>
<input type='hidden' name='CLINO' value='<?php echo $CLINO; ?>' />

Bob
This topic is locked and no more replies can be posted.