I have 2 scripts that I cannot seem to figure out how to merge.
- In script #1 - I read a URL and output the returned value(s). Usually just one.
- In script #2 - I write the results from one or more array(s) into lists.
SCRIPT #1:
function GetUrlValue(VarSearch){
var SearchString = window.location.search.substring(1);
var VariableArray = SearchString.split('&');
for(var i = 0; i < VariableArray.length; i++){
var KeyValuePair = VariableArray[i].split('=');
if(KeyValuePair[0] == VarSearch){
return KeyValuePair[1];
}
}
}
document.write(GetUrlValue('val1'));
document.write("<br>");
document.write(GetUrlValue('val2')); //only used if needed for a second list
document.write("<br>");
SCRIPT #2:
function ShowResults(value, index, ar) {
document.write(" • " + value);
document.write("<br />");
}
showCons = 'test this con';
showCaPS = 'caps...test this also';
showComm = 'test comm';
showDES = 'dis des, testing';
var divCons = [[showCons], [showCaPS], [showComm]];
var divCaPS = [[showCaPS], [showComm], [showCons], [showDES]];
var divComm = [[showComm], [showCons]];
var divDES = [[showDES]];
document.write("Cons header <br>");
divCons.forEach(ShowResults);
document.write("<br>");
document.write("CaPS header <br>");
divCaPS.forEach(ShowResults);
document.write("<br>");
I am not sure how in SCRIPT 1 if I pull a ?val1=cons, or whatever, that I could then tie that to the SCRIPT 2 and display the "var divCons" as a header with the 3 show### bullet points, or use val1=caps and show the 4 caps related show### bullets. And, then if a second set of information was needed to show, then just use the val2, and set that to whatever other value, like comm or des.
In short, instead of using the "document.write(GetUrlValue('val1'));" to output a value on the page, I need that same output value to be used as a variable that can trigger the "divCons.forEach(ShowResults);."
Be nice to me please, I am not a coder. This task is just falling on me because our core dev. team is currently not able to handle this work. Thanks in advance. :)
Any ideas?
Thanks.