473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

refreshing drop down menu

Hi basically my problem is I have 2 drop down menus populated by my database the first populated by a field in the database and the 2nd populated with a relation to the value selected in the first and basically i'm just havin a problem refreshing the menus after i submit a value or refresh the page. My code is below:

//javascript
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2.  
  3. function autoSubmit()
  4. {
  5.     var formObject = document.forms['theForm'];
  6.     formObject.submit();
  7. }
  8.  
  9. </script>
//php

[PHP]
$province = $site = null; //declare vars

if(isset($_GET["province"]))
{
$province = $_GET["province"];
}

if(isset($_GET["site"]) && is_numeric($_GET["site"]))
{
$city = $_GET["site"];
}

<form name="theForm" method="get">

<select name="province" onChange="autoSubmit();">
<option value="null">Province</option>

<?php

//POPULATE DROP DOWN MENU WITH PROVINCES

$sql = "SELECT DISTINCT Province FROM SAMP_SITE";
$provinces = mysql_query($sql);

while($row = mysql_fetch_array($provinces))
{
echo ("<option value=\"$row[Province]\" " . ($province == $row["Province"] ? " selected" : "") . ">$row[Province]</option>");
}

?>

</select>


<br><br>

<?php

if($province != null)
{

?>

<select name="site"">
<option value="null"></option>

<?php

//POPULATE DROP DOWN MENU WITH SITES GIVEN SELECTED PROVINCE

$sql = "SELECT SiteName,SAMP_SITE_ID FROM SAMP_SITE WHERE Province = '$province' ";
$sites = mysql_query($sql);

while($row = mysql_fetch_array($sites))
{
echo ("<option value=\"$row[SAMP_SITE_ID]\" " . ($city == $row["SAMP_SITE_ID"] ? " selected" : "") . ">$row[SiteName]</option>");
}

?>

</select>

<?php

}

?>
<input type='image' src='searchedirt.bmp' onClick='submit'>
</form>[/PHP]
Mar 6 '07 #1
2 2827
ronverdonk
4,258 Expert 4TB
Can't see what the problem is except for

1. enclosing this
Expand|Select|Wrap|Line Numbers
  1.  $province = $site = null; //declare vars
  2.  
  3. if(isset($_GET["province"])) {
  4.     $province = $_GET["province"];
  5. }
  6. if(isset($_GET["site"]) && is_numeric($_GET["site"])) {
  7.     $city = $_GET["site"];
  8. }
  9.  
within <?php and ?> tags.

2. removing the double quote in statement
Expand|Select|Wrap|Line Numbers
  1. <select name="site"">
It runs just fine at my server. At least it shows the second drop down.

After hitting the image it does not do anything but that is because you don't have a 'submit' routine (as specified in your 'onclick=' in the last input statement).

Ronald :cool:
Mar 6 '07 #2
Can't see what the problem is except for

1. enclosing this
Expand|Select|Wrap|Line Numbers
  1.  $province = $site = null; //declare vars
  2.  
  3. if(isset($_GET["province"])) {
  4.     $province = $_GET["province"];
  5. }
  6. if(isset($_GET["site"]) && is_numeric($_GET["site"])) {
  7.     $city = $_GET["site"];
  8. }
  9.  
within <?php and ?> tags.

2. removing the double quote in statement
Expand|Select|Wrap|Line Numbers
  1. <select name="site"">
It runs just fine at my server. At least it shows the second drop down.

After hitting the image it does not do anything but that is because you don't have a 'submit' routine (as specified in your 'onclick=' in the last input statement).

Ronald :cool:

Thanks Ronald for the lil quote error, but see it works right now but i want the menus to reload and show the null values once the page is refreshed or if they hit the back button after going to the submit routine. See right now if i hit the refresh button the menu will hold the last values i selected.
Mar 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: KK | last post by:
Drop-down menus are the hottest thing since Wonder Bread but . . . 1. Alot of people put them in the they-look-nice-but-you-cant-code-them-right-so-they-always-look-messed-up category (a la...
10
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the...
0
by: vikram.cvk | last post by:
Hello Experts, Im trying to design a CSS vertical drop down menu which should have the following functionality. Home About Us | -->Overview
2
by: hemanth.singamsetty | last post by:
Hello there, I've a drop down menu (created using CSS & Javascript -- see code below). My problem is, whenever I click a link on the menu the new page replaces the current page (and the menu...
4
by: simon.cigoj | last post by:
I have an javascript made menu and some forms with the dropdown element. When the menu opens and scrolls down the drop down is displeyed over the menu and obscures the menu choices. I have this...
1
by: phpnewb | last post by:
Hi, I know i'm doing it wrong, but I'm using a while loop right now to create several instances of a drop down menu. It gives me undesirable results. Can you tell me the right way to do it. Below are...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
1
by: Kaland | last post by:
Do the search engines follow links that are within forms (like the drop-down menu) so that those pages are indexed? Here is the code for a sample drop-down menu that I created. <form><select...
22
by: Archanak | last post by:
Hi, I am using 2-level CSS Drop Down Menu in my perl/CGI program. here is the code. #!c:/perl/bin/perl.exe use CGI qw(:standard);
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.