Open a modal via jquery on change

I am trying to open a modal in jquery on change of a select box.

There are multiple options in there one of which will redirect to a new window and one that I want to open a modal instead and load an external file.

The code that is currently working is here:
	$(".selectOpt").change(function() {
			var url = $(this).val();

Open in new window

How can I sent an attribute to that code, do an if statement to tell if it's that one specific option in the dropdown box and to open a modal with an external page instead of redirecting?

Who is Participating?

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

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.

If you want to maintain the URLs as the values in the select options you can do something like this.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" xml:lang="en" lang="en">
    <link rel="stylesheet" href="" />
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
                height: 800,
                width: 600,
                modal: true,
                autoOpen: false
                url = $('#selectOpt option:selected').val();
                if ($('#selectOpt option:selected').attr('class') === 'modal') {
                else if ($('#selectOpt option:selected').attr('class') === 'redirect') {
                else {
                    return false;
<select id="selectOpt">
    <option value="">&nbsp;</option>
    <option class="modal" value="./modal.html">Modal Page</option>
    <option class="redirect" value="./redirect.html">Redirect Page</option>
<div id="modal-window" title"This is modal window"></div>

Open in new window


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
ScotTFOAuthor Commented:
Worked perfect, thanks!
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

From novice to tech pro — start learning today.