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

前端 未结 3 429
再見小時候
再見小時候 2020-12-01 03:53

I have a vanilla html page which has a form in it. A requirement has come in to be able to pre-populate the form via the url. Something like:

http://some.s         


        
3条回答
  •  無奈伤痛
    2020-12-01 04:29

    Use a custom query string Javascript function.

    function querySt(ji) {
    
        hu = window.location.search.substring(1);
        gy = hu.split("&");
    
        for (i=0;i

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

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

提交回复
热议问题