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

  • Home
  • SEARCH
  • 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 7936353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:11:18+00:00 2026-06-03T22:11:18+00:00

I would like to add a small code snip to check out whether an

  • 0

I would like to add a small code snip to check out whether an option is selected
This usually is easily done if the page is html, now my code snip looks something like this

echo "<td>Language</td>";
echo "<td><select id='language' name='language'>
            <option value=''>Select...</option>
            <option value='en_US'>English(US)</option>
            <option value='en_AU'>English(AU)</option>
            <option value='en_UK'>English(UK)</option>
          </select><span id="info"></span>
      </td>";   

if it is html

<script>
   $('#language').change()
   {
     if('Select...'==$('#language').text())
     {
        $('#info').html("Please select a value...");
     }
   }
</script>

[UPDATE]

I would like to add that the above php source code used to generate html code is put in a form tag that is

echo "<form action='checkdb.php' method='POST'>
    // all above and more
    </form>"

the page checkdb.php used the posted data to update database.

How can I add in the jquery code piece as mentioned in the current file (the file with the html code is being generated) ? I am thinking as people once told me that javascript can’t be called in the middle of the php execution and I wonder if I may need to use ajax get function. Please offer some help. Thank you.

  • 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-06-03T22:11:19+00:00Added an answer on June 3, 2026 at 10:11 pm
    // Listen, and respond to, the change even on our select
    $("#language").on("change", function(e){
      // Set the html content of our info element
      $("#info").html(function(){
        // If the selected option has no value, ask to select a value
        return e.target.value === "" ? "Please select a value." : "" ;
      });
    // Trigger upon page load
    }).trigger("change");
    

    Demo: http://jsbin.com/owaqaz/2/edit

    Note the last line, $.trigger("change") – this will cause the page to immediately populate the #info element if the select element currently has no value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to add a small feature to QuantLib and compile it together
I would like to add an item into a picture Library using c#. This
Hello everybody, I have a small code in PHP that I would like to
I would like to add some paragraphs or new lines or words dynamically but
I would like to add a field to the Django FlatPage database model, but
I would like restfully add a parameter to the new named path. So for
I would like to add some custom data to an image the user generates
I would like to add authentication to my Rails app. I came across few
I would like to add an overlay image on a Google Map. The image
I would like to add a preprocessor to HTML pages. Basically, I have a

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.