homepage Welcome to WebmasterWorld Guest from 54.163.72.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
two combo boxes - can't clear second
onchange issue
jcolgate




msg:3475518
 2:27 am on Oct 12, 2007 (gmt 0)

Here's the run down:

first php page pulls values from mysql db for combo box # 1.
autotype
id name
---------
1 car
2 truck
3 SUV
4 unicycle

onchange=check_autotype(this.form.autotype_id.value)
- javascript processes the autotype_id through url to second php script

The output is sent to .innerHTML and creates combo box #1

A second php script pulls data for combo box # 2 based on the first combo box (second function).
autos
id list autotype_id
------------------
1 pink car 1
2 blue car 1
3 pickup 2
4 bmw 3
5 clowns 4
onchange=list_autos(this.form.autos_id.value)
- javascript processes the autos_id through url to a third php script

third php script pulls data detail for your select of the item from the second combo box.

The output is sent to .innerHTML and creates combo box #2

The page grows by your selections...

First comb box, then second, then details.

It works almost perfectly, when the second combo box changes, the details change with it. But when you change the first combo box, the details remain from the last choice. I wanted to find a way to run a command when the first combo box is changed that would reset the details either back to nothing and wait for you to select something on the second combo box again.

I tried concatenating a second command onto the first onchange, but it never worked.

I've searched the forums and found similar problems, but none that matched exactly.

Thank you all for your help in advance.

JColgate.

 

Arno_Adams




msg:3475735
 9:53 am on Oct 12, 2007 (gmt 0)

Hi,

Try:

document.getElementById('sel_box_2').options.length = 0

HTH, AA

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved