Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old March 29th, 2004, 12:24 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Drop Down Menus

Ok I have this code based on the Codewalkers tutorial:
php Code:
Original - php Code
  1.  
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  3. <html>
  4. <?PHP
  5. $link = mysql_connect("", "", "");
  6. mysql_select_db("", $link);
  7. ?>
  8. <head>
  9. <title>Untitled Document</title>
  10. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  11. <SCRIPT LANGUAGE="JavaScript">
  12. <!-- Original:  Jerome Caron (jerome.caron@globetrotter.net) -->
  13.  
  14. <!-- This script and many more are available free online at -->
  15. <!-- The JavaScript Source!! http://javascript.internet.com -->
  16.  
  17. <!-- Begin
  18.  
  19. team = new Array(
  20. new Array(
  21. new Array("Ryan Bleam"),
  22. new Array("Martin Rucinsky", 34802389),
  23. new Array("Jeff Hackett", 39823498),
  24. new Array("Sheldon Sourray", 87587343),
  25. new Array("Richard Zednik", 68798735),
  26. new Array("Brian Savage", 98098509),
  27. new Array("Stephane Robidas", 49490583),
  28. new Array("Patrice Brisebois", 32898334),
  29. new Array("Oleg Petrov", 92340934),
  30. new Array("Chad Kilger", 34923409),
  31. new Array("Benoit Brunet", 59384093),
  32. new Array("Jan Bulis", 83948023),
  33. new Array("Patrick Traverse", 41239812),
  34. new Array("Jose Theodore", 98402398),
  35. new Array("Craig Darby", 82393434),
  36. new Array("Patric Poulin", 34290348),
  37. new Array("Karl Dykhuis", 89092834)
  38. ),
  39. new Array(
  40. new Array("Mario Lemieux", 23840238),
  41. new Array("Jaromir Jagr", 92390484),
  42. new Array("Robert Lang", 29048203),
  43. new Array("Alexei Kovalev", 94098230),
  44. new Array("Jean-Sebastien Aubin", 39234923),
  45. new Array("Kevin Stevens", 29345423)
  46. ),
  47. null,
  48. new Array(
  49. new Array("Alexei Yashin", 20394802),
  50. new Array("Daniel Alfredson", 34982039),
  51. new Array("Marian Hossa", 92348902),
  52. new Array("Patrick Lalime", 98203894),
  53. new Array("Radek Bonk", 98234902)
  54. )
  55. );
  56. function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
  57. var i, j;
  58. var prompt;
  59. // empty existing items
  60. for (i = selectCtrl.options.length; i >= 0; i--) {
  61. selectCtrl.options[i] = null;
  62. }
  63. prompt = (itemArray != null) ? goodPrompt : badPrompt;
  64. if (prompt == null) {
  65. j = 0;
  66. }
  67. else {
  68. selectCtrl.options[0] = new Option(prompt);
  69. j = 1;
  70. }
  71. if (itemArray != null) {
  72. // add new items
  73. for (i = 0; i < itemArray.length; i++) {
  74. selectCtrl.options[j] = new Option(itemArray[i][0]);
  75. if (itemArray[i][1] != null) {
  76. selectCtrl.options[j].value = itemArray[i][1];
  77. }
  78. j++;
  79. }
  80. // select first item (prompt) for sub list
  81. selectCtrl.options[0].selected = true;
  82.    }
  83. }
  84. //  End -->
  85. </script>
  86.  
  87. </head>
  88.  
  89. <body>
  90. <?
  91. $query1 = "SELECT * FROM master Limit 0 , 1";
  92. $result1 = mysql_query($query1) or die('aa');
  93.  
  94. echo "<FORM NAME="main">";
  95. echo "<SELECT NAME="Make" onChange="fillSelectFromArray(this.form.Team, ((this.selectedIndex == -1) ? null : team[this.selectedIndex-1]));">";
  96. if (mysql_num_rows($result1) > 0) {
  97. for ($i = 0; $i<mysql_num_fields($result1); $i++) {
  98.     echo "<option value='arr".mysql_field_name($result1, $i)."'>".mysql_field_name($result1, $i)."</option>";
  99.     }
  100.     }
  101. echo "</SELECT>";
  102. ?>
  103. <BR>
  104. <SELECT NAME="Team" SIZE="5">
  105. <OPTION>                                  </OPTION>
  106. <OPTION>                                  </OPTION>
  107. <OPTION>                                  </OPTION>
  108. <OPTION>                                  </OPTION>
  109. <OPTION>                                  </OPTION>
  110. </SELECT>
  111. </FORM>
  112.  
  113. </body>
  114. </html>


At the top where it says new Array, how do I populate those arrays using PHP from data that is in my database. So for example whenever a field name is selected from the first drop down list I want it to list all of the values for that field in the next box. Hope someone can PLEASE help me out....

Reply With Quote
  #2  
Old March 29th, 2004, 12:30 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Drop Down Menus

Also I want to be able to submit the form to be processed as well....PLEASE Help I'm begging, I can't figure this out at all

Reply With Quote
  #3  
Old March 29th, 2004, 12:52 AM
Nicky's Avatar
Nicky Nicky is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Neverland
Posts: 606 Nicky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 26 sec
Reputation Power: 2
RE: Drop Down Menus

Check out this FAQ
http://codewalkers.com/faq/12/33.html

Reply With Quote
  #4  
Old March 29th, 2004, 12:58 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Drop Down Menus

That is the tutorial I used to get the first part to work, I just can't seem to figure out how to popuate the array based on which field name was selected. Right now it works and based on certain selections it displays the names that are in the array at the top...

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Drop Down Menus


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway