能从程序里取到struts标签<s:porperty>的值吗如要取得<s:property value="id">中id的值该怎么取

能从程序里取到struts标签<s:porperty>的值吗如要取得<s:property value="id">中id的值该怎么取,第1张

嗯嗯,我想你说的应该是要把id的值传到控制层去吧,如果你的控制层是Struts的话,那好办啊,只要用Javascript拿到id的值,再传到Action里面去就行了,呵呵,期待你的成功!

<input type="checkbox" name="student" value="1" data-age="18" />

<input type="checkbox" name="student" value="2" data-age="19" />

<input type="checkbox" name="student" value="3" data-age="20" />

var student = $("input[name='student']:checked")serialize();

$ajax({

url: "your-url",

type: "post",

data: student,

success: function (result) {

//handle

}

});

如果3个都是选中的状态的话,后台接收的数据为1,2,3

扩展资料:

关于jQuery对checkbox的其他 *** 作

1、根据id获取checkbox

$("#cbCheckbox1");

2、获取所有的checkbox

$("input[type='checkbox']");//or

$("input[name='cb']");

3、获取所有选中的checkbox

$("input:checkbox:checked");//or

$("input:[type='checkbox']:checked");//or

$("input[type='checkbox']:checked");//or

$("input:[name='ck']:checked");

4、获取checkbox值

//用val()即可,比如:

$("#cbCheckbox1")val();

5、获取多个选中的checkbox值

var vals = [];

$('input:checkbox:checked')each(function (index, item) {

valspush($(this)val());

});

6、判断checkbox是否选中(jquery 16以前版本 用  $(this)attr("checked"))

$("#cbCheckbox1")click(function () {

if ($(this)prop("checked")) {

alert("选中");

} else {

alert("没有选中");

}

});

7、设置checkbox为选中状态

$('input:checkbox')attr("checked", 'checked');//or

$('input:checkbox')attr("checked", true);

8、设置checkbox为不选中状态

$('input:checkbox')attr("checked", '');//or

$('input:checkbox')attr("checked", false);

9、设置checkbox为禁用状态(jquery<16用attr,jquery>=16建议用prop)

$("input[type='checkbox']")attr("disabled", "disabled");//or

$("input[type='checkbox']")attr("disabled", true);//or

$("input[type='checkbox']")prop("disabled", true);//or

$("input[type='checkbox']")prop("disabled", "disabled");

10、设置checkbox为启用状态(jquery<16用attr,jquery>=16建议用prop)

$("input[type='checkbox']")removeAttr("disabled");//or

$("input[type='checkbox']")attr("disabled", false);//or

$("input[type='checkbox']")prop("disabled", "");//or

$("input[type='checkbox']")prop("disabled", false);

<ul > <ol> <li class="opened"><span class="liststyle"></span><a href="#">搜索1</a><p class="clear"></p></li><!--二级menu--> <li class="opened"><span class="liststyle"></span><a href="#">搜索2</a><p class="clear"></p></li> <li class="opened"><span class="liststyle"></span><a href="#">搜索3</a><p class="clear"></p></li> <li class="opened"><span class="liststyle"></span><a href="#">搜索4</a><p class="clear"></p></li> </ol> </ul> $("a")click(function(){ var obj2 = thisparentNode; alert($(obj2)id);

//$(obj2)addClass("listactive"); //$(obj2)css("class","listactive")

看行吗;

不清楚你在问什么

<button id="ss">商品id</button>

<button onclick="xxx('')">跳转页面按钮</button>//xxx('')改成xxx('跳转到指定网址')则跳转到指定网址

<script>

function xxx(ww){var u=documentgetElementById("ss")innerHTML;

if(ww!=""){windowlocationassign(ww);

}else{windowlocationassign("indexhtml"+u);获取按钮上的id跳转到页面,id=1跳转到indexhtml1,id=2跳转到indexhtml2

}

}

1,如果你没用struts2框架的话,requestgetAttribute("id")

2,如果你使用了struts2框架的话,你只用在action中设置一个叫id的属性,并给它get,set方法(这里只会用到get方法)。struts2框架会自动赋值你的id属性,你直接使用就可以了。

以上就是关于能从程序里取到struts标签<s:porperty>的值吗如要取得<s:property value="id"/>中id的值该怎么取全部的内容,包括:能从程序里取到struts标签<s:porperty>的值吗如要取得<s:property value="id"/>中id的值该怎么取、jquery,ajax 如何提交多个checkbox的值、JQuery怎么在页面上子类获取父类的id值,是用Struts2标签循环读取出来的等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9645630.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-30
下一篇2023-04-30

发表评论

登录后才能评论

评论列表(0条)

    保存