The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
Form Builder and GET - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8)
+--- Forum: Modules (https://forums.formtools.org/forumdisplay.php?fid=16)
+--- Thread: Form Builder and GET (/showthread.php?tid=1911)



Form Builder and GET - sandrews - Feb 22nd, 2012

I'm looking at the Form Builder module in terms of converting some existing forms. I have a few forms where the end user is first presented with a drop-down list containing company names. Once the user selects their company from that drop-down, I use an onchange to wisk them to the actual form, where their basic info (email, address, etc. ) is then pre-populated by way of a database query using a GET variable that was set along the way. The individual fields just echo'd a variable if it was set. So, my question is can this, or something similar to this, be done using Form Builder?


RE: Form Builder and GET - Ben - Feb 25th, 2012

Hi sandrews,

Sorry for not getting back to you sooner on this!

Interesting case. Yes, the Form Builder could certainly help: but it may take a little custom work to get it set up the way you want. The first page (the one containing the dropdown with the onchange), I would still leave outside of the Form Builder + have it just link to the Form Builder form with the appropriate GET variable.

In the form builder page itself (i.e. the "Form Page" template of the template set you're using), you'll need to extract that variable and use it to populate your fields. Perhaps the simplest way to do this is with jQuery. For example:

Code:
{{if $smarty.get.company_name == "Company1"}}
<script>
$(function() {
  $("#field1").val("Your value");
});
</script>
{{/if}}

What that code does is: if the query string contains "company_name=Company1", it outputs some JS to the page which runs on page load. That code populates the field with ID field1 with a value of "Your value".

That's the general idea: depending on how your form is arranged, it would need some tweaking though.

- Ben



RE: Form Builder and GET - sandrews - Mar 30th, 2012

Ben,

I just got back to working on this, and tried your suggestion. I can't seem to get the field value(s) to set and appear. The smarty.get portion is working, as I can display that query string value in the form (inserting <h2>{{$smarty.get.name}}</h2> at the top for example). I made sure to change the field name(s) to what I am using on the particular form of course. I'm just not sure why it isn't working. I even tried referencing the fields by name versus id without success. Any thoughts?


RE: Form Builder and GET - sandrews - Apr 10th, 2012

I did manage to get this working! I used this in the form page template:

Code:
<script>
  function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}
  
var company1 = unescape(getQuerystring('company'));
var address1 = unescape(getQuerystring('address'));

</script>

{{if $smarty.get.company != ""}}
<script>
$(function() {
  $("input[name=comp]").val(company1);
});
</script>
{{/if}}

{{if $smarty.get.address != ""}}
<script>
$(function() {
  $("input[name=add]").val(address1);
});
</script>
{{/if}}