Im trying to decode the %20 in the URL link so that i cant get my value without adding %20 in the textfield when i decode the code from current page to next page, below is my coding for decode the %20 and where i place
function loadRecord(i){
var item=dataset.item(i);
fname.value = item['fname'];
id.value = item['id'];
window.location.href = decodeURIComponent("userup2.html?id="+item['id']+"&fname="+item['fname']+"&val=300");
return false;
}
This is the current and will redirect to second page to display the data
why it still display the %20 even though i code the decodeURIComponent? please help
You have to decode the URI when it's passed to your input. Decoding it to pass it to window.location
is correct, but the browser will escape it again.
I assume you take the input value from the params. So where you set the input value from the params (in your case, certainly in the document userup2.html
, you have to decode the URI.
So where you set the input value from the params, you have to decode it again:
document.getElementByTagName('input').value = decodeURI(...your code to get the params);