当用户点击“下一步”按钮时,来自两个单独文本框的数据将传输到新页面,但是%20代替空格应该在哪里。我怎么能避免这种情况?
来自originalpage.html的内联javascript
$('#next').click(function(){
var coachFullName = $('#coach_txt_box').val();
var teamName = $('#team_txt_box').val();
if(!!coachFullName){
window.location.href = 'newpage.html?zip=' + coachFullName + teamName;
} else {
$('# coach_txt_box').watermark('please enter coach name',{className: 'watermarkError'});
}
});
来自newpage.html的内联javascript
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null)
return "";
else
document.signupform.coach_and_team_name.value = results[1];
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
getParameterByName('coach');