Prank Posted February 16, 2006 Share Posted February 16, 2006 Hi Guys,I am having a brain fart and cant seem to work out how to do this....My 2 tables;[code]phones_man+-------+--------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+-------+--------------+------+-----+---------+----------------+| id | int(11) | | PRI | NULL | auto_increment || name | varchar(100) | | | | |+-------+--------------+------+-----+---------+----------------+phones_mod+--------+--------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+--------+--------------+------+-----+---------+----------------+| id | int(11) | | PRI | NULL | auto_increment || name | varchar(100) | | | | || man_id | int(100) | | | 0 | |+--------+--------------+------+-----+---------+----------------+[/code]Ok, what I am trying to do is populate a drop down box using the results from phones_man and then populating the 2nd drop down box with the models that match the manufacturer selected in the first box. Does that make sense? The other alternative is to have 1 box list all the manufacturers and models like such;man1_mod1man1_mod2man1_mod3man2_mod1man2_mod2 etc...Either is fine, the first method would probably utilise a javascript auto form submit to populate the 2nd box i would think..Either way, Advice needed. :)Thanks very much.Christianedit - damn whitespace is ignored... there goes that formatting :(mod edit: use [code] and your whitespaces are back :) Quote Link to comment Share on other sites More sharing options...
fenway Posted February 16, 2006 Share Posted February 16, 2006 You'd have to use JavaScript either way, unless you're going to go the IFRAME/XMLHttpRequest route. And since that's the case, it makes sense simply to output both tables to a JS array, and then have one drop-down update the other. There are many tutorials on how to accomplish this.From a MySQL standpoint, this is trivial, since you're getting back all the rows. Quote Link to comment Share on other sites More sharing options...
Prank Posted February 17, 2006 Author Share Posted February 17, 2006 [!--quoteo(post=346493:date=Feb 17 2006, 06:54 AM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Feb 17 2006, 06:54 AM) [snapback]346493[/snapback][/div][div class=\'quotemain\'][!--quotec--]You'd have to use JavaScript either way, unless you're going to go the IFRAME/XMLHttpRequest route. And since that's the case, it makes sense simply to output both tables to a JS array, and then have one drop-down update the other. There are many tutorials on how to accomplish this.From a MySQL standpoint, this is trivial, since you're getting back all the rows.[/quote]Awesome, thanks - I did end up using javascript but its so messy and I hate messy code.Anyhoo, thanks again. Quote Link to comment Share on other sites More sharing options...
fenway Posted February 17, 2006 Share Posted February 17, 2006 Glad you got it working. Don't take this the wrong way, but if it's messy, it's usually incorrect -- you may want to find a better tutorial / source code example. Off the top of my head, you should be able to do it in under 10 lines of JS code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.