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 9113065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:53:02+00:00 2026-06-17T03:53:02+00:00

I have a drop down menu and an empty select box below: <select name=session

  • 0

I have a drop down menu and an empty select box below:

<select name="session" id="sessionsDrop">
    <option value="">Please Select</option>
    <option value='20'>EWYGC - 10-01-2013 - 09:00</option>
    <option value='22'>WDFRK - 11-01-2013 - 10:05</option>
</select> </p> 

$studentSELECT = "";  
$studentSELECT .= '<select name="studenttextarea" id="studentselect" size="6">';
$studentSELECT .= '</select>'; 

The above is in the addstudent.php page:

Now what happens is that I have a php code where depending on which assessment is chosen from drop down menu, it runs a query and it displays either a list of students in the select box if rows from the db are found, if no rows are found then it simply displays a message stating that no students were found within an assessment in the select box. The code for this is below which is in the addedstudents.php page and is accessed through ajax.

$studentnum = $currentstudentstmt->num_rows();   
$studentSELECT = "";     

if($studentnum == 0){
    $studentSELECT .= "<option disabled='disabled' class='red' value=''>No Students currently in this Assessment</option>"; 
} else {   
    while ( $currentstudentstmt->fetch() ) {
       $studentSELECT .= sprintf("<option disabled='disabled' value='%s'>%s - %s %s</option>", $dbStudentId, $dbStudentAlias, $dbStudentForename, $dbStudentSurname) . PHP_EOL; 
    }
}

echo $studentSELECT;

The problem I have is that if the user selects the Please Select option, it still displays the message stating no assessments are found, this is because obviously there are no modules in this query so it thinks that as it has no rows display the message. But I don’t want this to be dislayed if the Please Select option is selected, I just want the select box to just be empty.

Problem is that even though I tried to use jquery to do this, what happens is the select box goes empty but then comes back with the message milliseconds later.

My question is that if the Please Select option is chosen from drop down menu, what is best way to be able to display an empty select box?

Below is attempt of this through jquery:

$('#sessionsDrop').change( function(){
    if( $(this).val() == '' ){
        $('#studentselect').val('');                   
    }
});
  • 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-17T03:53:03+00:00Added an answer on June 17, 2026 at 3:53 am

    youy have 2 options for this; either filter it on the UI level or on the server level or both.

    1.) on the js/jquery level (i will just have to give you a description/pseudocode so that you will be the one interpreting this)

    Filter out if the value of the selected is "" then dont proceed;
    Same with @vortextangent’s answer only check if $('#sessionsDrop').val() != "" should you proceed

    2.) on the server side level i’d assume that before you could query your db you have this
    $_POST['session'] or $_GET['session'] which contains the value of the dropdown

    you just have to catch it if $_POST['session'] or $_GET['session'] will both be '' (empty space) and you should not continue with the db query

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

Sidebar

Related Questions

I have a drop down menu below: <select name=session id=sessionsDrop> <option value=>Please Select</option> <option
Basically, I have drop down menu that looks like this: <select> <option>0</option> <option selected=selected>1</option>
I have a drop down menu. Has product types. Product types have associated value
I have this drop down menu.It stores month, Jan-Dec. User can choose any value
I have a drop down menu. I use it to select a particular Tea.
Hi I have problem with IE9. I have drop down menu with select boxes
I have a drop down menu. By default it allows only one option to
I have a drop down menu which displays an exam's name, date and time
I have a drop down menu below: $form = <form action=' . htmlentities($_SERVER[PHP_SELF]) .
I need to have a drop-down menu that allows you to select a year

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.