javascript - Change the URL with a GET method -
is there way submit selected fields url method ?
by clicking on button, want put string on url, using method.
expected result: test.html?test=11,13,21,34&somewords=1,2,3&demo=2
yes! example :
function submit() { var test = document.getelementbyid('test').value; var demo = document.getelementbyid('demo').value; var somewords = document.getelementbyid('somewords').value; var url = 'test.html?test=' +test + '&somewords=' + somewords + '&demo=' + demo; console.log(url); // test.html?test=1,2,3,4&somewords=noting&demo=2 // code request }
html
<input type="text" value="1,2,3,4" id="test"> <input type="text" value="noting" id="somewords"> <input type="text" value="noting" id="dummy"> <input type="text" value="2" id="demo"> <button onclick="submit()">submit</button>
live example : https://jsbin.com/cayude/edit?html,js,console,output
hope helps. !
Comments
Post a Comment