How to automatically pass url variable to a form?

  • Profile Image
    redpoints
    Asked on July 26, 2011 at 06:20 PM

    HEllo, I am going to publish one form on many pages on my websites. Is there any way to pass url from wich the form came?

    I know I can do something like this: http://www.jotform.com/form/11530401402?url=http://strefasingla.pl but this is manual for every occurence of the form on each site.

    Can I do something like this? http://www.jotform.com/form/11530401402?url={url_variable} where url_variable is dynamically changed depending on site where the form is being used. I'd be very greateful fo your help.

    Thank you for your great work.

  • Profile Image
    NeilVicente
    Answered on July 26, 2011 at 06:44 PM

    Hi,

    Absolutely. What you want to achieve is already being used by many of our users. An in-depth discussion regarding this system can be found in this thread.

    If you have further questions about that particular solution, please let us know. You can post your questions on that thread. Thanks!


    Neil

  • Profile Image
    redpoints
    Answered on July 26, 2011 at 07:19 PM

    Thank you for your help. I used advice from that thread: http://www.jotform.com/help/60-How-to-find-out-the-address-of-the-page-from-which-a-submission-came 

    Unfortunatelly I have some problems with validation (the form leads to Thank you page whough it isn't validated correctly, probably because of joomla issues). The pageAddress is sent correctly. 

    Is it possible to pass pageAddress variable with simple script embedding?

  • Profile Image
    NeilVicente
    Answered on July 26, 2011 at 07:30 PM

    Hi,

    I think you have gone to a different link. Please use the exact link below:

    http://www.jotform.com/answers/19992-How-Can-I-Differentiate-When-I-Use-the-Same-Form-on-Different-Sites

    This solution uses iframe embed codes so you won't have issues with scripts and stuff. I am afraid that the solution offered in the link you posted does not work for most of our users due to JavaScript conflicts.


    Neil

  • Profile Image
    redpoints
    Answered on July 27, 2011 at 03:41 AM

    Dear Neil,

    The solution from the example will always give me the same variable, which is 'google' and IMHO is not an equivalent for "pageAddress solution". What should I do if I want to know url address of the site without altering the form script code for each site. In joomla I have a module with a form which is published for 20 sites (offers). I want to know from which site the form data comes from. I don't want to alter the form for each site separately with ?website=page1, ?website=page2 and so forth.

  • Profile Image
    aytekin
    Answered on July 27, 2011 at 07:48 AM

    1. Create a hidden field and call it "website".

     

    2. Add ?website=page1 to the URL

    3. When you receive the submission email or go to submissions/report pages you should see the website variable in the results.

     

    Submit this form to see it working live:

    https://www.jotform.com/form/12074504792?website=123

     

  • Profile Image
    redpoints
    Answered on July 27, 2011 at 08:49 AM

    Hello,

    thank you for your kind help.

    As I stated bfore - in my first post -  I've already been using it. That simply means that the exactly the same form script code has to be altred with different value for 'website' variable. I need the website variable value to be collected AUTOMATICALLY, not manually for each site I use the form.

    I feel so misunderstood :( I need the exact working solution, as it was proposed here  http://www.jotform.com/help/60-How-to-find-out-the-address-of-the-page-from-which-a-submission-came 

    With that script I could publish one form which coudl be attached to 1000 diffrent sites and without altering form script code I always could get the exact url the data came from. 

    Now I guess it's not possible anymore which bothers me a lot :(.

  • Profile Image
    aytekin
    Answered on July 27, 2011 at 10:12 AM

    Sorry for the misunderstanding. You can probably use PHP or JavaScript to edit the URL and change the website variable. unfortunately, it is not possible for JotForm to automatically detect it.

  • Profile Image
    redpoints
    Answered on July 27, 2011 at 01:08 PM

    Hello,

    thank you for your advice.

    I made something like this: 

    When looking into the code it is ok: http://sitename.pl/index.php?option=com_content&Itemid=203&id=385&lang=pl&task=view

    But after sending the form, both in confirmation email and in database, I get the url stripped to the first ampersand so the url is unusable. Namely I only get:

    http://sitename.pl/index.php?option=com_content

    Does anyone has an idea how I can fix this? 

    I could probably use urlencode() on the url but where in the process could urldecode() be used to give me a proper link both in confirmation email and in database?

  • Profile Image
    liyam
    Answered on July 29, 2011 at 04:34 AM

    Hello redpoints,

    I'm not sure how or why it is stripping ampersands.  Maybe you will need to find a way how to string replace '&' to '%26'.  as soon as your page receives the URL value, from there on you can start the process or url.  I'm not sure as well that you will need to use urldecode() in PHP when you can simply use $_GET[] as this is already decoded.

    Warm regards,

    Liyam