This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Need help with hidden fields with dynamic content


  1. samerbazzi
    Member

    OK, I have been working on adding some hidden fields, I am actually adding a really nice feature, I will populate data such as City, State, Zip, etc. I get this information by getting the IP and than running it through an outside API which sends back the information, I have the data, no problem,

    Now I have the Iframe version working fine, no problems at all, I send the hidden fields data in the iframe URL as explained in another post on this forum,

    Here is the code I use for the IFrame version and it works perfectly fine:

    <iframe id="the_iframe" onLoad="calcHeight();" height="400" allowtransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none" src="/form-lead-management/embed.php?id=3&county=<?php

    /**
    * Example 1
    *
    * Declaration of GeoIPLocator and it's simplest examples
    */

    // Include GeoIPLocator (path to source classes)
    include("/home/content/v/b/x/vbxlms/html/geo/GeoIPLocator.class.php");

    // Instance
    $geoip = new GeoIPLocator($_SERVER['REMOTE_ADDR']);

    // Getting IP Info (IPAddress Instance)
    $info = $geoip->getIPInfo();

    // Getting Information about current IP
    // See API Documentation of IPAdress class for supported attributes

    # Getting city name (if it's available)
    echo $info->getCityName();
    echo "";

    ?>" title="Contact Residential Home ">Contact Residential Home </iframe>

    What the code above does is add the city name that is looked up by the geo location script to the end of the URL, I than add the following code to the view-functions.php like this

    if($form_id == 3 && $row['element_id'] == 6){
    $element[$j]->default_value = $_GET['county'];

    It works fine, everything is great,

    Now my headache, I have tried some things but just cant get the embed code to work,

    Yes, I know you have to add the above code in view-functions twice, that is fine, I have no problem with that, and when I tried to access an example page where I access the embed form and add some values to the url, for example: embed-example.php?id=3&county=test_test_city it works fine, but I need to use the following code for the script to get the city for me so I can dynamically pass it like I do for the iframe version,

    Now, I know, I know, people may say to use the Iframe version, I can't, When I finish this project, I will explain in more detail, I use JQuery and Sortable and everything but IE has a problem with dragging Iframes and Div content, all kinds of refresh issues, etc.

    So basically I have everything working, I just need to know where to place this code below where it is passed to the hidden field for embed mode since I have the IFrame version working fine,

    <?php

    /**
    * Example 1
    *
    * Declaration of GeoIPLocator and it's simplest examples
    */

    // Include GeoIPLocator (path to source classes)
    include("/home/content/v/b/x/vbxlms/html/geo/GeoIPLocator.class.php");

    // Instance
    $geoip = new GeoIPLocator($_SERVER['REMOTE_ADDR']);

    // Getting IP Info (IPAddress Instance)
    $info = $geoip->getIPInfo();

    // Getting Information about current IP
    // See API Documentation of IPAdress class for supported attributes

    # Getting city name (if it's available)
    echo $info->getCityName();
    echo "";

    ?>

    I hope someone can help, I have done so much work with this system, if anyone needs help with integration with salesforce, mail chimp, jquery, making it look pretty, etc, let me know,

    -Sam

    Posted 14 years ago #
  2. yuniar

    Try to put those code directly into your view-functions.php file, particularly inside display_integrated_form() function.

    Search around line 2036:

    $element[$j]->default_value = htmlspecialchars($row['element_default_value']);

    below that line, you can add your code like this:

    if($form_id == 3 && $row['element_id'] == 6){
    
      // Include GeoIPLocator (path to source classes)
      include("/home/content/v/b/x/vbxlms/html/geo/GeoIPLocator.class.php");
    
      // Instance
      $geoip = new GeoIPLocator($_SERVER['REMOTE_ADDR']);
    
      // Getting IP Info (IPAddress Instance)
      $info = $geoip->getIPInfo();
    
      // Getting Information about current IP
      // See API Documentation of IPAdress class for supported attributes
    
      # Getting city name (if it's available)
      $element[$j]->default_value = $info->getCityName();
    }

    MachForm Founder

    Posted 14 years ago #
  3. samerbazzi
    Member

    it works, thank you soooo much :)

    Excellent A+++ support,

    -Samer

    Posted 14 years ago #
  4. mikimiki
    Member

    hey, amerbazzi, I need this to ! I wa sjust posted about it!, Can I get you script version, please? you cam email me here: crv747 at gmail.com

    Posted 14 years ago #

RSS feed for this topic

Reply