struts2中js中的值如何传给action急!!

Bymyeclipse 2012-05-07 03:22:18
在页面的js中写了一个方法

function getRadio(){

$(document).ready(function(){

$('#tab input').each(function(){
var a = $(this).is(':checked');
if(a){
var Objmsg = $(this).parent().nextAll('td:first');
Objmsg.each(function(){
msgid=$(this).text();
});
alert(msgid);
}
});
});
}

在页面的一个from中调用这个function

<s:from action="gotoupdate" theme="simple" id="updatemessage">
<s:iterator value="#request.pmlist" status="st" id='listid'>
<tr class="a1" style="border-bottom: 2px solid #9AC3E3;">
<td width="21px"><input name="radio" type="radio" value=""/></td>
<td width="22px"><s:property value="msg_id"/></td>
<td width="80px"> <s:property value="stype"/></td>
<td width="80px"><s:property value="lan"/></td>
<td width="52px"><s:property value="msg_type"/></td>
<td width="250px"><s:property value="question_describe"/></td>
<td width="250px"><s:property value="question_analyse"/></td>
<td width="275px"><s:property value="answer"/></td>
<td width="49.5px"><s:property value="ur_id"/></td>
<td width="58.5px"><s:property value="question_type"/></td>
<td width="70px"><s:property value="question_person"/></td>
<td width="70px"><s:property value="phone"/></td>
<td width="60px"><s:property value="begin_time"/></td>
<td width="60px"><s:property value="by_person"/></td>
<td width="60px"><s:property value="iphone"/></td>
<td width="60px"><s:property value="end_time"/></td>
<td width="54px"><s:property value="by_system"/></td>
<td width="58px"><s:property value="question_emergency"/></td>
<td width="58px"><s:property value="responsibility"/></td>
</tr>
</s:iterator>
<input type="submit" id="updatemsg" onclick="getRadio();"

style="width:80px;position:absolute;top:485px;left:290px" value="处理">
</s:form>


目的是得到我选中的单选框的那条记录中的第一个值,也就是页面元素msg_id的值。
现在使用这段js代码可以得到,但是我现在要把这个值传入到后台的action里面去处理,请问怎么做!
...全文
175 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Bymyeclipse 2012-05-15
  • 打赏
  • 举报
回复
自问自答吧:
在js里面加上

//给某个页面元素赋值
document.getElementById("getid").value=msgid ;

在HTML加上

<s:hidden name="updatemessage.msg_id" id="getid"></s:hidden>

然后就可以和表单信息一起提交到后台了!
xushilin000000000 2012-05-08
  • 打赏
  • 举报
回复
<s:from是什么东西?做事认真一点嘛。可以把脚本中的值放到表单隐藏域中一起提交。

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧