How can I pre-populate html form input fields from url parameters?

Use a custom query string Javascript function.

function querySt(ji) {

    hu = window.location.search.substring(1);
    gy = hu.split("&");

    for (i=0;i<gy.length;i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}
var koko = querySt("koko");

Then assign the retrieved value to the input control; something like:

document.getElementById('mytxt').value = koko;

Leave a Comment