Open new HTML page via javascript and pass parameters

前端 未结 1 499
遇见更好的自我
遇见更好的自我 2021-01-07 07:12

I am completely new to javascript and web development and have a question. I have two HTML files, one includes a search field and a search button, the other one should (late

相关标签:
1条回答
  • 2021-01-07 07:33

    Your sending the entire object to the page, while you should send just its value.
    Use this code to get the value of an input :

    var value = document.getElementById("input").value;
    

    Then, it's really simple to redirect to other page sending data via URL. You just need to redirect adding a parameter like this :

    window.location.href = "searchresult.html?city="+value;
    
    0 讨论(0)
提交回复
热议问题