I have written the script below to pull in data from a url string and then place in preexisting (un-editable) form fields.
<script>
var Month = getQueryVariable("Month");
function getQueryVariable(variable) {
var query = window.location.search.replace("?", "");
for (var vars = query.split("&"), i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (decodeURIComponent(pair[0]).replace("+", " ") == variable) {
return decodeURIComponent(pair.slice(1).join("=")).replace("+", " ");
}
}
return "NONE"
}
</script><script type="text/javascript">
document.getElementById('Month').readOnly = true;
</script>
I am able to pull in the data from the url just fine. However I get an error when submitting, and upon inspecting the element, it appears the value that was passed has tripled! Any idea what is causing this and how I can prevent it? My assumption is it is something with the autotab.
<input id="Month" name="Month" class="month autotab autotabdate" type="text" value="12,12,12" size="2" maxlength="2" readonly="">
URL used is: https://test.com/welcome.html?Month=12
` then you have to supply the field with the value after making it readonly `document.getElementById('Month').value = Month;`
– SaidbakR Apr 30 '15 at 23:01