I was getting the output as follows:美好的一天, 我正在创建一个Suitelet表单,并尝试通过将其附加到url并调用另一个Suitlet来传递参数,同时在调用的Suitelet中访问参数时,所有空格都被替换为'%20',如何摆脱此空间问题< / p>
define(['N / search'],
功能(搜索){
/**
* Definition of the Suitelet script trigger point.
*
* @param {Object} context
* @param {ServerRequest} context.request - Encapsulation of the incoming request
* @param {ServerResponse} context.response - Encapsulation of the Suitelet response
* @Since 2015.2
*/
function onRequest(context) {
if (context.request.method === 'GET'){
var html='';
html+='<head><title>RESUME</title></head>';
html+='<body><form><div align=center>NAME:<input type="text" id="name"><br></div><br>';
html+='<div align=center>addrline1:<input type="text" id="addr1"><br></div><br>';
html+='<div align=center>addrline2:<input type="text" id="addr2"><br></div><br>';
html+='<div align=center>addrline3:<input type="text" id="addr3"><br></div><br>';
html+='<div align=center>city:<input type="text" id="city"><br></div><br>';
html+='<div align=center>email:<input type="email" id="email"><br></div><br>';
html+='<div align=center>phone:<input type="phone" id="phone"><br></div><br>';
html+='<div align=center>objective:<input type="longtext" id="objective"><br></div><br>';
html+='<div align=center>gap1:<input type="text" id="gap1"><br></div><br>';
html+='<div align=center>gap2:<input type="text" id="gap2"><br></div><br>';
html+='<div align=center>gap3:<input type="text" id="gap3"><br></div><br>';
html+='<div align=center>colz1:<input type="text" id="colz1"><br></div><br>';
html+='<div align=center>colz2:<input type="text" id="colz2"><br></div><br>';
html+='<div align=center>colz3:<input type="text" id="colz3"><br></div><br>';
html+='<div align=center>cour1:<input type="text" id="cour1"><br></div><br>';
html+='<div align=center>cour2:<input type="text" id="cour2"><br></div><br>';
html+='<div align=center>cour3:<input type="text" id="cour3"><br></div><br>';
html+='<div align=center>year1:<input type="text" id="year1"><br></div><br>';
html+='<div align=center>year2:<input type="text" id="year2"><br></div><br>';
html+='<div align=center>year3:<input type="text" id="year3"><br></div><br>';
html+='<button onclick="myFunction()">Click me</button>';
html+='<script "type=text/javascript">'+myFunction+'</script>';
html+='</form></body>';
context.response.write(html);
}
function myFunction(){
var Name=document.getElementById('name').value;
window.alert(Name);
var addr1=document.getElementById('addr1').value;
window.alert(addr1);
var addr2=document.getElementById('addr2').value;
window.alert(addr2);
var addr3=document.getElementById('addr3').value;
window.alert(addr3);
var city=document.getElementById('city').value;
window.alert(city);
var email=document.getElementById('email').value;
window.alert(email);
var phone=document.getElementById('phone').value;
window.alert(phone);
var objective=document.getElementById('objective').value;
var colz1=document.getElementById('colz1').value;
var colz2=document.getElementById('colz2').value;
var colz3=document.getElementById('colz3').value;
var cour1=document.getElementById('cour1').value;
var cour2=document.getElementById('cour2').value;
var cour3=document.getElementById('cour3').value;
var gap1=document.getElementById('gap1').value;
var gap2=document.getElementById('gap2').value;
var gap3=document.getElementById('gap3').value;
var year1=document.getElementById('year1').value;
var year2=document.getElementById('year2').value;
var year3=document.getElementById('year3').value;
var url = "/app/site/hosting/scriptlet.nl?script=2225&deploy=1";
window.alert(url);
url = url+"&Name="+Name;
window.alert(url);
url+="&addr1="+addr1;
window.alert(url);
url+='&addr2='+addr2;
window.alert(url);
url+='&addr3='+addr3;
window.alert(url);
url+='&city='+city;
window.alert(url);
url+='&email='+email;
window.alert(url);
url+='&phone='+phone;
url+='&objective='+objective;
url+='&colz1='+colz1;
url+='&colz2='+colz2;
url+='&colz3='+colz3;
url+='&cour1='+cour1;
url+='&cour2='+cour2;
url+='&cour3='+cour3;
url+='&year1='+year1;
url+='&year2='+year2;
url+='&year3='+year3;
url+='&gap1='+gap1;
url+='&gap2='+gap2;
url+='&gap3='+gap3;
window.open(url);
window.close( "https://system.netsuite.com/app/site/hosting/scriptlet.nl?")
// replace("url", ' ', '%20');
}
}
return {
onRequest: onRequest
};
}); 这是所谓的套件:
define(['N / render','N / file'],
function(render,file){
/**
* Definition of the Suitelet script trigger point.
*
* @param {Object} context
* @param {ServerRequest} context.request - Encapsulation of the incoming request
* @param {ServerResponse} context.response - Encapsulation of the Suitelet response
* @Since 2015.2
*/
function onRequest(context) {
var username=context.request.parameters.Name;
log.debug(username);
var Addr1=context.request.parameters.addr1;
log.debug(Addr1);
var Addr2=context.request.parameters.addr2;
log.debug(Addr2);
var Addr3=context.request.parameters.addr3;
log.debug(Addr3);
var City=context.request.parameters.city;
log.debug(City);
var Email=context.request.parameters.email;
log.debug(Email);
var Phone=context.request.parameters.phone;
log.debug(Phone);
var objective=context.request.parameters.objective;
var gpa1=context.request.parameters.gap1;
var gpa2=context.request.parameters.gap2;
var gpa3=context.request.parameters.gap3;
var colz1=context.request.parameters.colz1;
var colz2=context.request.parameters.colz2;
var colz3=context.request.parameters.colz3;
var cour1=context.request.parameters.cour1;
var cour2=context.request.parameters.cour2;
var cour3=context.request.parameters.cour3;
var year1=context.request.parameters.year1;
var year2=context.request.parameters.year2;
var year3=context.request.parameters.year3;
var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE pdf PUBLIC \"-//big.faceless.org//report\" \"report-1.1.dtd\">\n";
xml += "<pdf>";
xml += "<body>";
xml +="<p align='center'>"+username+"</p>";
xml+="<table width='100%'><tr><td width='75%'>"+Addr1+"</td><td width='25%'>"+Email+"</td></tr>";
xml+="<tr><td width='75%'>"+Addr2+"</td><td width='25%'>"+Phone+"</td></tr>";
xml+="<tr><td>"+Addr3+"</td></tr></table>";
xml+="<hr></hr>";
xml+="<div><p style='word-wrap: break-word;'><b><u>CarrerObjective:</u></b>"+objective+"</p></div>";
xml+="<p><b>Education Qualification:</b></p>"
xml+="<table width='100%' style='border: 1px solid black; text-align: left;'>";
xml+="<tr><th style='border: 1px solid black'>University</th><th style='border: 1px solid black'>year of passing</th><th style='border: 1px solid black'>GPA</th><th style='border: 1px solid black'>Course</th></tr>";
xml+="<tr><td style='border: 1px solid black'>"+colz1+"</td><td style='border: 1px solid black'>"+year1+"</td><td style='border: 1px solid black'>"+gpa1+"</td><td style='border: 1px solid black'>"+cour1+"</td></tr>";
xml+="<tr><td style='border: 1px solid black'>"+colz2+"</td><td style='border: 1px solid black'>"+year2+"</td><td style='border: 1px solid black'>"+gpa2+"</td><td style='border: 1px solid black'>"+cour2+"</td></tr>";
xml+="<tr><td style='border: 1px solid black'>"+colz3+"</td><td style='border: 1px solid black'>"+year3+"</td><td style='border: 1px solid black'>"+gpa3+"</td><td style='border: 1px solid black'>"+cour3+"</td></tr>";
xml+="</table>";
xml +="</body></pdf>";
var pdfFile = render.xmlToPdf({
xmlString: xml
});
log.debug('pdfFile',pdfFile);
context.response.writeFile(pdfFile);
}
return {
onRequest: onRequest
};
});
在pdf文件中,所有空格都已替换为%20