function submitForm(){
    var returnArray = [];//对象数组
    
    //var checkbox = $("input:checkbox");
    //$("input:checked",checkbox);
    //选中的ID
    $("input[name='box']").each(function(){
        if($(this).attr("checked")){
                var $tr = $(this).parent("td").parent("tr");//.siblings()
                var $tds = $tr.find("td");
                var ID = $(":hidden[name='ID']",$tds.eq(1)).val();// val()的要处理成\n
                ID = ID.replace(/\n/gm,"<br\>");
                
                var content = $tds.eq(2).text();// text的要处理成\r
                content = content.replace(/\r/gm,"<br\>");
            
                //传回调用界面的逻辑
                var jsonstr = '{"ID":"'+ID
                +'","content":"'+content
                +'"}';
                returnArray.push(jsonstr);
        }
    });
    window.returnValue=returnArray;
    window.close();
}

<form id="form" action="" method="post">
<table>
<s:iterator value="contents" status="status" >
<tr <s:if test="#status.index%2==0">class="eve"</s:if>
<s:if test="#status.index%2==1">class="odd"</s:if> align="center">
<td ><input type="checkbox" name="box" /></td>
<td><s:property value="#status.index+1"/><s:hidden name="ID" value="%{}"></s:hidden><td>
<td><s:textarea readonly="true" name="content" value="%{}"  cssStyle="width:100%;height:auto;"></s:textarea></td>
<td ><s:select disabled="true" list="#{'0':'a','1':'b'}" value="%{}" cssStyle="width:99%"></s:select></td>
</tr>
</s:iterator>
<a id="" href="javascript:void(0);"  οnclick="submitForm();">确定</a>
</table>
</form>    

//主页面处理逻辑
var vReturn = window.showModalDialog(sURL,vArguments,sFeatures);
    if(undefined !=vReturn && $.isArray(vReturn)){
        $.each(vReturn, function(key, val) {
            var jsons = jQuery.parseJSON(val);
                var idj = jsons.ID ;
                var contentj = jsons.content;
            
                //在转义回来,统一转义成 \n
                var idvalue = idj.replace(/<br\>/gm, "\n");
                var contentvalue = contentj.replace(/<br\>/gm, "\n");
    });
}

转载于:https://my.oschina.net/u/1182621/blog/151384

GitHub 加速计划 / js / json
50
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 天前 )
dff2b475 Adds pre-multiplication overflow detection to catch cases where dimension products would exceed size_t max. The previous check only detected when overflow resulted in exactly 0 or SIZE_MAX, missing other cases. Retains the original post-multiplication check for backward compatibility. Adds tests verifying overflow detection with dimensions (2^32+1)×(2^32), which previously overflowed silently to 2^32. This prevents custom SAX handlers from receiving incorrect array sizes that could lead to buffer overflows. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi> 15 小时前
eef76c20 * :white_check_mark: add test for C++20 modules Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :rotating_light: fix warning Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Add missing header (#4763) * :bug: add missing header Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :rotating_light: fix warning Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :rotating_light: fix warning Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me> 1 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐