Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6152943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:00:32+00:00 2026-05-23T20:00:32+00:00

I’m trying to get the selected value from a drop down list via jQuery.

  • 0

I’m trying to get the selected value from a drop down list via jQuery. I have a bit of javascript that validates a form when I click SEND, to make sure there are no blanks, code is as follows:

function formCheckDancer(formobj){                  
            // Enter name of mandatory fields
            var fieldRequired = Array("dancerStageName", "dancerFullName", "dancerPhone", "dancerEmail", "dancerCountry", "dancerAvailableDate");

            // Enter field description to appear in the dialog box
            var fieldDescription = Array("Stage Name", "Full Name", "Phone Number", "Email Address", "Nationality", "Availability");

            // dialog message
            var alertMsg = "Please complete the following fields:\n";           
            var l_Msg = alertMsg.length;

            for (var i = 0; i < fieldRequired.length; i++){
                var obj = formobj.elements[fieldRequired[i]];               
                if (obj){
                    switch(obj.type){
                    case "select-one":                      
                        if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "" || obj.options[obj.selectedIndex].text == "..."){
                            alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                    case "select-multiple":
                        if (obj.selectedIndex == -1){
                            alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                    case "text":
                    case "textarea":
                        if (obj.value == "" || obj.value == null){
                            alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                    case "checkbox":
                        if (obj.checked == false){                  
                            alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                    default:
                    }
                    if (obj.type == undefined){
                        var blnchecked = false;
                        for (var j = 0; j < obj.length; j++){
                            if (obj[j].checked){
                                blnchecked = true;
                            }
                        }
                        if (!blnchecked){
                            alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                    }
                }
            }

            if (alertMsg.length == l_Msg){
                return sendDetailsDancer(); //Send email if all field are populated.
                return true;                
            }else{
                alert(alertMsg);
                return false;
            }
        }

        function sendDetailsDancer(){                       
            var stagename = $("input[name=dancerStageName]").val();         
            var fullname = $("input[name=dancerFullName]").val();
            var phone = $("input[name=dancerPhone]").val();
            var email = $("input[name=dancerEmail]").val();                                                                                             
            var nationality = $("#dancerCountry").val();            
            var availability = $("input[name=dancerAvailableDate]").val();    

            $("#contact_form_result_dancer").html('<center><img src="loading.gif" width="32" height="32" /></center>');
            $("#contact_form_result_dancer").show();
            $.post("http://localhost/lapello/wp-content/themes/lapello/sendMailDancer.php", {stagename: stagename, fullname: fullname, phone: phone, email: email, nationality: nationality, availability: availability}, function (data){
                $("#contact_form_result_dancer").html(data);            
            });
            setTimeout("contactReturnDancer()", 4000);
            return false;
        }

In this case Nationality is the value I want. As you can see I’ve tried:

var nationality = $("#dancerCountry").val();

which doesn’t seem to work.

If I put the following alert statement: alert(obj.options[obj.selectedIndex].text); after case “select-one” the correct value is output so I know its being passed correctly.

I’m just not sure how to capture it in the sendDetailsDancer function.

Any help appreciated.

Regards,
Stephen

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:00:33+00:00Added an answer on May 23, 2026 at 8:00 pm

    var nationality = $("#dancerCountry").val(); should work. Are you sure that the element selector is working properly? Perhaps you should try:

    var nationality = $('select[name="dancerCountry"]').val();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.