How to get selected value (id) from lookup field using javascript (jQuery)

Hi,
I need to get lookup fields selected item value ( i mean not a text value, but lookup item ID ) on my new/edit item form by using jscript ( jQuery ) from lookup field with more than 20 items and also from multi-value lookup.

I can find, change options, get text value, but not an ID of selected item. Well it coud be possible to find ID by listing all options in lookup, but what if i got 2 or more items with same title?

Thanks.
ian_stAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ian_stAuthor Commented:
Solved for lookup with more than 20 items.
var optHid = $(YourField).find ('input').attr('optHid');
var ID = $(hid).attr('value');

ID will contain selected item value.
0
EE_AutoDeleterCommented:
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.

EE_AutoDeleter
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.