Welcome to WebmasterWorld Guest from 54.144.243.34

Forum Moderators: open

two combo boxes - can't clear second

onchange issue

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

5+ Year Member



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.

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

10+ Year Member



Hi,

Try:


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

HTH, AA

 

Featured Threads

Hot Threads This Week

Hot Threads This Month