Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown Pick list question 1

Status
Not open for further replies.

fatdog302

Technical User
Jun 12, 2002
26
AU
First of all I apologise if this isn't the most appropriate forum to post this thread but i dont have all that much knowledge in this area and i generally think that Javascipt cures all. If it recommended that I post this in another forum please let me know.

Now to the problem...

I have a simple dropdown with continents and some of their respective countries/states. When 'droped down' it looks something like this:

AUSTRALIA
ACT
New South Wales
Northern Territory
Queensland

AFRICA
South Africa
Africa Other

ASIA
China
Indonesia
Other Asia

EUROPE
United Kingdom
Other Europe

NORTH AMERICA
Canada
USA

SOUTH AMERICA
Chile
Peru
Other South America

They are all records in the same table just the continents have a field 'iscontinent' set to true. The main records in the database are only linked to the country/state records, so the continents are there only to act as headings in the drop down. Is there anyway to restict the continents from being selected? At the moment if it is select and the user searches then it brings up an error, id prefer if they didnt have the ability to select in the first place.


Thanks
Costa
 
Hi-

You have to create a javascript function that will check if the selection is a valid one or not. In the SELECT tag place and ONCLICK event handler to go to the function mentioned above and use SWITCH to check for a valid selection...

Ex. <select name=&quot;test&quot; onClick=&quot;check()&quot;>

<script>
function check(dato){
switch (dato){
case &quot;AUSTRALIA&quot;:
return;
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top