简体   繁体   中英

How to get value from HTML to Suitescript?

I am writing a suitelet in suitescript 2.0 which contains an html part. I need to get the value from html form to a variable in suitelet

/**
 * @NApiVersion 2.x
 * @NScriptType Suitelet
 */
define([ 'N/http', 'N/email', 'N/record' ,'N/runtime'], 

        function(http, email, record,runtime) {     

 function onRequest(context) {
    function sendGetRequest() {

         var param= http.get({
            url : ''
    });
        var html = '<html><body>something: '
                     + something
                     + '<br/>'
                     +'<form method="post">Input  <input type="text" name="something" id="something" value=""/> <input type="submit"/> </form></body></html>'; 
             log.debug({title : 'param', details : param});
      context.response.write(html);
      var something = html.getParameter('something');
      log.debug({title : 'something', details : something});

        }

    sendGetRequest();

}

return {
    onRequest: onRequest
};

});

在Suitelet上获得的所有内容都在上下文对象上,如果要特定的HTML数据,则必须使用客户端脚本将其放在表单字段之一中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM