From: Joey Schulze Date: Thu, 4 Mar 2010 14:34:02 +0000 (+0100) Subject: Add general function to set variables from the frontend X-Git-Tag: 2010-06-02_customer~136 X-Git-Url: https://git.infodrom.org/?p=misc%2Fkostenrechnung;a=commitdiff_plain;h=3e1c59ad30f2b2cd3d0fca135b6f8ecd0739d8d6 Add general function to set variables from the frontend --- diff --git a/lib/functions.js b/lib/functions.js index da031ea..d575cb6 100644 --- a/lib/functions.js +++ b/lib/functions.js @@ -71,6 +71,25 @@ function set_value(id, value) obj.selectedIndex = i; } +function setvar(obj, name, callback, status) +{ + if (!obj.options[obj.selectedIndex].value.length) + value = -1; + else + value = obj.options[obj.selectedIndex].value; + + var source = document.getElementById('source'); + + if (!source) return false; + + var parms = 'source=' + source.innerHTML + '&name=' + name + '&value=' + value; + + ajax_request('setvar', parms, callback); + + if (typeof status == 'function') + status(obj,value,obj.options[obj.selectedIndex].innerHTML); +} + /* * Form functions */