homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
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

5+ Year Member

Msg#: 3475516 posted 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.
id name
1 car
2 truck
4 unicycle

- 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).
id list autotype_id
1 pink car 1
2 blue car 1
3 pickup 2
4 bmw 3
5 clowns 4
- 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.




10+ Year Member

Msg#: 3475516 posted 9:53 am on Oct 12, 2007 (gmt 0)



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


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