Skip to content

Commit d5b5208

Browse files
authored
rely on field name instead of field id
1 parent 2a74224 commit d5b5208

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
How to use this script:
33
1. Add a hidden form field for each query string parameter you’d like to capture.
4-
The field’s name and id should match the key of the query string parameter.
4+
The field’s name should match the key of the query string parameter.
55
2. Include the script on the page(s) where you’d like to use it, and activate it in your JavaScript:
66
queryForm({reset: true});
77
The value {reset: true} is optional. Including it will clear (reset) parameter values after a form is submitted.
@@ -23,6 +23,6 @@ var queryForm = function(settings){
2323
var hiddenFields = document.querySelectorAll("input[type=hidden]");
2424
for (var i=0; i<hiddenFields.length; i++) {
2525
var param = sessionStorage.getItem(hiddenFields[i].name);
26-
if (param) document.getElementById(hiddenFields[i].name).value = param;
26+
if (param) document.getElementsByName(hiddenFields[i].name)[0].value = param;
2727
}
2828
}

0 commit comments

Comments
 (0)