Need help with javascript to read URL data

jflash

Member
I redirect one form with 'Append jump url with data' option to another. Now i want to read data from URL to find show or hide element. URL looks like:
HTML:
http://www.mypage.eu/index.php/vali-mang-ja-suuna?12tulem___valimang[value]=2&12tulem___kasutaja[value]=46&12tulem___nimo_a=0&12tulem___hausenberg_a=0&12tulem___lukjanov_a=0&12tulem___paabut_a=0
When 12tulem___paabut_a value is 0 i want to hide element:
$('12sessioonid___liiga').getParent().getParent().hide();
I tried three different codes i found on internet, but no one work. If i put '$('12sessioonid___liiga').getParent().getParent().hide();' in element javascript onload action, it hides the element, so that is correct...

First code. I use QueryData javascript and call it from /components/com_fabrik/js/formnumber.js and it is included. My code in javascript onload action:
Code:
var getData = new QueryData();
if ('12tulem___paabut_a' in getData){
  if (getData.12tulem___paabut_a == '0'){
$('12sessioonid___liiga').getParent().getParent().hide();
  }
else {

  }
}
Second code:
Code:
window.params = function(){
var params = {};
var param_array = window.location.href.split('?')[1].split('&');
for(var i in param_array){
x = param_array[i].split('=');
params[x[0]] = x[1];
}
return params;
}();
if(window.params.12tulem___paabut_a == 0) {
$('12sessioonid___liiga').getParent().getParent().hide();
}
Third code:
Code:
function $_GET(q,s) {
s = (s) ? s : window.location.search;
var re = new RegExp('&'+q+'=([^&]*)','i');
return (s=s.replace(/^\?/,'&').match(re)) ?s=s[1] :s='';
}
var value = $_GET('12tulem___paabut_a');
if(window.params.12tulem___paabut_a == 0) {
$('12sessioonid___liiga').getParent().getParent().hide();
}
 
I did it and describe to others too. My first form sends data to another form with 'Append jump url with data' option. Now i use javascript in /components/com_fabrik/js/formnumber.js and script is:
Code:
var GETDATA = new Array();
var sGet = window.location.search;
if (sGet) // if has a value...
{
sGet = decodeURIComponent(sGet);
sGet = sGet.substr(1);
    // Generate a string array of the name value pairs.
    // Each array element will have the form "foo=bar"
    var sNVPairs = sGet.split("&");
    // Now, for each name-value pair, we need to extract
    // the name and value.
    for (var i = 0; i < sNVPairs.length; i++)
    {
        // So, sNVPairs[i] contains the current element...
        // Split it at the equals sign.
        var sNV = sNVPairs[i].split("=");
        // Assign the pair to the GETDATA array.
        var sName = sNV[0];
        var sValue = sNV[1];
        GETDATA[sName] = sValue;
    }
}
Now, i need to read data from URL (example: index.php?value1=0&value2=1) and find show or hide element on form. On elemet javascript option i use 'load' action with code:
Code:
if(GETDATA['value1'] == 0) {
$('tablename___elementname').getParent().getParent().hide();
}
On my example URL value1 is 0, so form hides the element. It is not good solution but works and enough for me :)
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top