开发者

Getting form object values in a script

开发者 https://www.devze.com 2023-03-23 14:04 出处:网络
If you have this kind of form att开发者_JAVA百科ribute in Spring: <form:select path=\"form_object.id\" items=\"${objects}\" itemValue=\"id\" itemLabel=\"description\">

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

精彩评论

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