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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:26:07+00:00 2026-05-24T00:26:07+00:00

I have two select boxes, the second of which is dependent upon the selection

  • 0

I have two select boxes, the second of which is dependent upon the selection in the first. I want to get the second select box (course) to have a value of null when the first box (subject) is changed. Any help on accomplishing this would be greatly appreciated.

This is what I have tried:

Javascript:

function autoSubmit() {
    var formObject = document.forms['theForm'];
    formObject.submit();
}

PHP:

<form name="theForm" method="get">
<select name="subject" onChange="autoSubmit();">
<option value="null">Select a Subject...</option>

<php
$sql = "SELECT DISTINCT subj_name, subj_id FROM table1 ORDER BY subj_name
$result = mysql_query($sql) or die ("couldn't execute query");

while($row = mysql_fetch_array($result))
{
echo ("<option value=\"$row[subj_id]\" " . ($subject == $row["subj_id"] ? " 
  selected" : "") . ">$row[subj_name]</option>");        
}
?>          
</select>

<select name="course" onChange="autoSubmit();">        
<option value="null">All Courses</option>        
<php
if($subject != null && is_numeric($subject))
{

$sql = "SELECT DISTINCT subj_id, course_id, course_name FROM table1 
  WHERE subj_id = $subject ORDER BY course_name
$result = mysql_query($sql);

while($row = mysql_fetch_array($result))
{
echo ("<option value=\"$row[course_id]\" " . ($course == $row["course_id"] ? 
  " selected" : "") . ">$row[course_number] - $row[course_name]</option>");        
}
}

?>
</select>
</form>
  • 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-24T00:26:07+00:00Added an answer on May 24, 2026 at 12:26 am

    You can put in the onChange of the first select, before the autoSubmit() :

    this.form.course.value='null';
    

    or

    this.form.course.selectedIndex=0;
    

    This way the value on the get will be ?subject=[the_subject]&course=null ( and then $course == $row["course_id"] will be false ).

    ( http://jsfiddle.net/HMT34/ )

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

Sidebar

Related Questions

I have two pages. One with the select boxes on and the send button.
I have I have two pages. One with the select boxes on and the
I have a weird problem , below are two simple get calls and returning
I setup two arrays: 1) the class names and the value names 2) the
I have two forms here. Registration and Payment . In the registration form i
I have an ASP.NET dropdownlist called #ddlDateRange that contains several items. Possible values in
I am developing a c# winform app which controls a website using web browser.
Hi Guys i need some help with Jquery Validadion Plugin I have an input
I need to write an application in VB6 which makes a scatter plot out
I am developing a small scale app using smart gwt 2.4. I chose smart

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.