I was wondering if you could give me some insight on what I can do when it comes to passing url parameters in the url to a specific page on my jquery mobile run site.
So I have a link living on site A that look like this: http://www.m.mysite.org/donate?s_src=1234&s_subsrc=12345
And if someone clicks on that link I am then taken to my mobile site where I have a donation form. within the donation form I have two hidden fields called
<input type="hidden" id="source" value="" />
<input type="hidden" id="sub_source" value="" />
I want to grab the values of those parameters and fill those values that maybe empty or not. This is the script that I have to grab those parameters and their values:
var source = getUrlVars()["s_src"];
var subsourc = getUrlVars()["s_subsrc"];
if (source != "" && source != 'undefined' && source != null) {
document.getElementById('source').value = source;
}
if (subsourc != "" && subsourc != 'undefined' && subsourc != null) {
document.getElementById('sub_source').value = subsourc;
}
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
Problem is that these values are not being applied to those hidden input fields.
getUrlVars()function is working?getUrlVars()in my plug-in which could cause issues with your function