autofill with javascript

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Philippe_de_Nice
Posts: 3
Joined: 2014-06-12 07:18

autofill with javascript

Post by Philippe_de_Nice » 2014-10-23 14:09

Hello everyone,

We use a little javascript code to automatically complete a number a fields according to a field values.
This code is located in the tablename-dv.js file and is triggered when a button is clicked. It looks like:

form.elements['some input field''].value='default value';
...
...

The issue is that since a AppGini upgrade (probably 5.0, but I'm unsure of this), this automatic way of filling forms does not work anymore.
More precisely, it is still working for simple text input, but not anymore for the lists. (<select>).

If anyone can help...

Thank you,
Philippe

udayvatturi
AppGini Super Hero
AppGini Super Hero
Posts: 85
Joined: 2014-06-14 03:08
Location: India
Contact:

Re: autofill with javascript

Post by udayvatturi » 2014-10-29 06:19

Hi,
I did bit research and i observed few things. May be that will help you..
When i didnt select any values in the drop down the html content is like this

Code: Select all

<div class="select2-container" id="s2id_ClientName-container" style="width: 100%;">
<a href="javascript:void(0)" onclick="return false;" class="select2-choice" tabindex="-1">   
<span class="select2-chosen"><None></span>
<abbr class="select2-search-choice-close"></abbr>   
<span class="select2-arrow"><b></b></span></a>
<input class="select2-focusser select2-offscreen" type="text" id="s2id_autogen4">
</div>
Following is the HTML code when i selected an item

Code: Select all

<div class="select2-container" id="s2id_ClientName-container" style="width: 100%;">
<a href="javascript:void(0)" onclick="return false;" class="select2-choice" tabindex="-1">  
<span class="select2-chosen">Uday Vatturi</span>
<abbr class="select2-search-choice-close"></abbr>   
<span class="select2-arrow"><b></b></span></a>
<input class="select2-focusser select2-offscreen" type="text" id="s2id_autogen4">
</div>
There is change in line 3. So may be you can just try changing the value of that particular node.

That may help. I am not sure if this works.

Philippe_de_Nice
Posts: 3
Joined: 2014-06-12 07:18

Re: autofill with javascript

Post by Philippe_de_Nice » 2014-11-04 18:42

Hello,
Intensive use of Google lead me to the answer. For those having a similar issue, simply note this: for the javascript part, appgini has moved from Prototype to another framework named Jquery.

A good explanation and quick howto can be find here:
http://gneady.com/category/javascript/

guess who is the author ;-)

User avatar
a.gneady
Site Admin
Posts: 1287
Joined: 2012-09-27 14:46
Contact:

Re: autofill with javascript

Post by a.gneady » 2014-11-04 20:52

Good dig, Philippe!

Newer versions of AppGini (5.20 and above) use a third-party component for drop-downs called select2. See: http://ivaynberg.github.io/select2/

From the above link, to change the value of a drop-down:

Code: Select all

$("#e8").select2("val", "CA");
where e8 is the ID of the container of the drop down (for AppGini apps, the ID is fieldname-container, where fieldname is the name of the drop-down field), "CA" is the new value. So, the code should be:

Code: Select all

jQuery("#fieldname-container").select2("val", "new-value");
Note that we are using jQuery rather than $ in the above code to avoid conflicts with Prototype framework as both jQuery and Prototype are used (we plan to remove Prototype gradually in future releases).
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

Post Reply