Avatar of MJ
MJ
Flag for United States of America asked on

Detect Value in Select Using JavaScript Only (No jQuery)!

If you go to https://apply.essexcredit.com/ on the first page, you'll see a select "What type of loan are you interested in? ". I need to set an event listener on this element and grab the value being selected.(RV or Boat).  Javascript only. Please see image

Screenshot of select
*** I can't touch/change the code on the page. I have to use a TMS to inject my code. ***

Thanks!
Web DevelopmentJavaScript* HTML 5jQuery

Avatar of undefined
Last Comment
Michel Plungjan

8/22/2022 - Mon
Daniel Pineault

I think this is what you are after


BLINK LINK REMOVED

MJ

ASKER

Hi Daniel,

Unfortunately that won't work. It is a SPA and I'm using a TMS.  I have to attach an event listener to it once it loads and then detect the value selected. Once the virtual page changes, I will detach the listener. 

ASKER CERTIFIED SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
MJ

ASKER

Leakim,

Did you mean for the second function to be a "remove"?


Thanks,

MJ

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
MJ

ASKER

Thank you both!

leakim971

the second function?
your post said you want to detect a value when it change

the following line get the value and set it to title
do what you want with it
I use it to do an alert

var title = found.getAttribute("title" );

Open in new window

MJ

ASKER

Hi,

No, originally your code was duplicated? It is not there any longer.


Thanks!

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
leakim971

you right, bad copy/paste copy/paste copy/past/... copy/paste
Michel Plungjan

Here is a shorter jQuery version


It will work as long as the select is the 4th in the page and needs to be tested to see if the value changed


$(document).on("click", function() { console.log($("div select:eq(3)").val()) })

Open in new window