开发者

Getting form object values in a script

If you have this kind of form att开发者_JAVA百科ribute in Spring:

<form:select path="form_object.id" items="${objects}" itemValue="id" itemLabel="description">

How can you pass the id (type is int) value to script?

$("#form_object").change(function(){
 alert($(this.val));

this.val returns nothing. I need to posses the id value of selected item.


You've written:

alert($(this.val));

instead, try:

alert($(this).val());

the .val property of this is probably undefined, so when you get the jQuery selector undefined, you get undefined back from jQuery.

Maybe I'm misreading this? If you just need the id of an <input>, use view-source or Chrome's right click -> inspect element feature to find the id.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜