Hello,
1. I have the following script:
function selectThis(id){
var locationstring = "process.php?value=" + id; /////
locationstring += "&bs=" + $('#bs_' + id).attr("selectedIndex");
locationstring += "&ad=" + $('#ad_' + id).attr("selectedIndex");
locationstring += "&ns=" + $('#ns_' + id).attr("selectedIndex");
locationstring += "&wt=" + $('#wt_' + id).attr("selectedIndex");
locationstring += "&in=" + $('#in_' + id).attr("selectedIndex");
document.location.href = locationstring;
}
With it I am getting a string with the value of the clicked button from an array and some other select field values that are listed in the same set of mysql results as the clicked button.
BUTTON:
<input name="button" type="button" onclick="selectThis('<? echo $rows; ?>');" value="">
At the end of the script the page is redirected to in the script mentioned page with following string:
process.php?value=1&bs=2&ad=3&ns=4&wt=5&in=6
(values are not real, so whatever the chosen value of the select field should apear in the link.)
THIS WORKS FINE.
2. My problem is following:
In order to be able to use var locationstring in other scripts as well I have removed var and have made it global.
function selectThis(id){
locationstring = "process.php?value=" + id; /////
locationstring += "&bs=" + $('#bs_' + id).attr("selectedIndex");
locationstring += "&ad=" + $('#ad_' + id).attr("selectedIndex");
locationstring += "&ns=" + $('#ns_' + id).attr("selectedIndex");
locationstring += "&wt=" + $('#wt_' + id).attr("selectedIndex");
locationstring += "&in=" + $('#in_' + id).attr("selectedIndex");
}
The problem is that later on when I use locationstring variable in other script I get only first variable in the string
process.php?value=1
instead of
process.php?value=1&bs=2&ad=3&ns=4&wt=5&in=6
3. Is it possible to make locationstring variable global and in a single line in order to be able to use the full string in other scripts or is there another solution.
Thank in advance.