Hi all, i hope someone can help me out.
I have a tabular search form with details form.
I have implemented default values on the dropdowns in the search form.
The defaults are set in the datapageready and beforeformsubmit events using localstorage,
This works fine from the desktop chrome browser but not from my mobile phone also using chrome browser.
Here is the code snippet:
<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
if (typeof(Storage) !== "undefined") {
if(localStorage.getItem("continent") !== null && localStorage.getItem("continent") !== "") {
document.getElementsByName("Value2_1")[0].value = localStorage.getItem("continent");
} else {
document.getElementsByName("Value2_1")[0].value = "1";
}
} else {
alert ("Sorry! No Web Storage support..");
}
// stop for sometime if needed
setTimeout(setCountry, 1000);
});
function setCountry() {
if (typeof(Storage) !== "undefined") {
if(localStorage.getItem("country") !== null && localStorage.getItem("country") !== "") {
document.getElementsByName("Value3_1")[0].value = localStorage.getItem("country");
} else {
document.getElementsByName("Value3_1")[0].value ="1";
}
} else {
alert ("Sorry! No Web Storage support..");
}
var event = new Event('change');
document.getElementsByName("Value3_1")[0].dispatchEvent(event);
// stop for sometime if needed
setTimeout(setLanguage, 1000);
}
function setLanguage() {
if (typeof(Storage) !== "undefined") {
if(localStorage.getItem("language") !== null && localStorage.getItem("language") !== "") {
alert ("Language is already set in DataPageReady to " + localStorage.getItem("language"));
document.getElementsByName("Value4_1")[0].value = localStorage.getItem("language");
} else {
document.getElementsByName("Value4_1")[0].value = "1";
}
} else {
alert ("Sorry! No Web Storage support..");
}
var event = new Event('change');
document.getElementsByName("Value4_1")[0].dispatchEvent(event);
// stop for sometime if needed
setTimeout(setCultureFeature, 1000);
}
function setCultureFeature() {
if (typeof(Storage) !== "undefined") {
if(localStorage.getItem("culturefeature") !== null && localStorage.getItem("culturefeature") !== "") {
document.getElementsByName("Value5_1")[0].value = localStorage.getItem("culturefeature");
} else {
document.getElementsByName("Value5_1")[0].value = "6";
}
} else {
alert ("Sorry! No Web Storage support..");
}
var event = new Event('change');
document.getElementsByName("Value5_1")[0].dispatchEvent(event);
}
document.addEventListener('BeforeFormSubmit', function (event) {
if (typeof(Storage) !== "undefined") {
localStorage.setItem("continent",document.getElementsByName("Value2_1")[0].value);
localStorage.setItem("country",document.getElementsByName("Value3_1")[0].value);
localStorage.setItem("language",document.getElementsByName("Value4_1")[0].value);
localStorage.setItem("culturefeature",document.getElementsByName("Value5_1")[0].value);
} else {
alert ("Sorry! No Web Storage support..");
}
});
</script>