Hi all,
Could the "magic" javascript described here http://bigprof.com/appgini/help/advance ... agic-files be used to set field values when another field changes?
If so, is there a reference somewhere?
Best regards,
Gerard.
Use of javascript magic hooks
Re: Use of javascript magic hooks
Yes it could, the "tablename-dv.js" file. Maybe something like this:
In the above code, changing field1 would set field2 to 'new value'.
Code: Select all
jQuery(function(){
jQuery('#field1').change(function(){
jQuery('#field2').val('new value');
});
});
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.
Re: Use of javascript magic hooks
Thanks a lot, ahmad. I'll try it asap.
Re: Use of javascript magic hooks
Ok, here's the result of 1 hour of fumbling with javascript (simplified a lot for instructive purposes):
// Sets total field to read-only
document.getElementById("total").readOnly = true;
// set event hooks
$('qty').observe('change', qtyOrPriceChanged);
$('price').observe('change', qtyOrPriceChanged);
// hook function
function qtyOrPriceChanged(event) {
calc();
}
// calc function
function calc()
{
var qty = $("qty").value;
var price = $("price").value;
var total = qty * price;
$('total').value = total;
}
It works! (And it reminds me why I like Object pascal ).
BTW, does anybody know if there is a way to get some error message when the javascript is incorrect, instead of nothing happening?
best regards,
Gerard.
// Sets total field to read-only
document.getElementById("total").readOnly = true;
// set event hooks
$('qty').observe('change', qtyOrPriceChanged);
$('price').observe('change', qtyOrPriceChanged);
// hook function
function qtyOrPriceChanged(event) {
calc();
}
// calc function
function calc()
{
var qty = $("qty").value;
var price = $("price").value;
var total = qty * price;
$('total').value = total;
}
It works! (And it reminds me why I like Object pascal ).
BTW, does anybody know if there is a way to get some error message when the javascript is incorrect, instead of nothing happening?
best regards,
Gerard.
Re: Use of javascript magic hooks
And trickier question: how could i detect a dropdown list (referenced table) changing?
Cheers,
Gerard.
Cheers,
Gerard.
Re: Use of javascript magic hooks
Install Firebug plugin for Firefox and open the console then reload the current page to see if there are any javascript error messages.BTW, does anybody know if there is a way to get some error message when the javascript is incorrect, instead of nothing happening?
Lookups use "select2" component. Please refer to the events section of select2 documentation: http://ivaynberg.github.io/select2/#documentationhow could i detect a dropdown list (referenced table) changing
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.
Re: Use of javascript magic hooks
I'm sorry to bother you again, but I cannot find the select2 component in the loaded page.
Re: Use of javascript magic hooks
Use an expression like this:Replace 'fieldname' above with the lookup field name, and "command" with the select2 command you want to execute (as detailed in the select2 documentation)
Code: Select all
jQuery('#fieldname-container').select2('command');
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.
Re: Use of javascript magic hooks
Hi guys, i have stumbled on this thread and it happens to be something that i am fighting with for about 2 days now. I am trying to get the command for accessing the text of the selected value on the dropdown menu. I am only able to retrieve the ID using the 'val' command. Please help me. What is the command to get text. Also can i have a link to this documentation you speak of.
Re: Use of javascript magic hooks
I answered you in the other thread.
/Giuseppe
Professional Outsourcing Services
Professional Outsourcing Services
Re: Use of javascript magic hooks
nice ,but i would like to ask
what if i would like change #field2 in other table .... ( not same table )
#field1 in table name ( AAAA )
#field2 in table Name ( BBBB )
if #field1 change , #field1 change ??????
what if i would like change #field2 in other table .... ( not same table )
#field1 in table name ( AAAA )
#field2 in table Name ( BBBB )
if #field1 change , #field1 change ??????