943,083 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 2570
  • PHP RSS
Jan 31st, 2010
0

populating second drop down list box based on the selection of the first

Expand Post »
Hi i m trying to create two drop down list boxes where the second drop downl list box is populated based on the selection of the first one.I have searching the net for days and even the scripts i downloaded don't seem to be working..Can anyone help me plz.....Its urgent...I have deadline approaching....
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nlal is offline Offline
23 posts
since Jan 2010
Jan 31st, 2010
0
Re: populating second drop down list box based on the selection of the first
This looks like a javascript problem to me. When is your deadline?

Larry
Reputation Points: 12
Solved Threads: 4
Newbie Poster
Larry_b is offline Offline
16 posts
since Jan 2010
Jan 31st, 2010
0
Re: populating second drop down list box based on the selection of the first
Hi,

I don't know Javascript all that well. Here is a script I wrote 4 years ago when I was first learning web design. It does what you say you want. Maybe it will give you some ideas.

PHP Syntax (Toggle Plain Text)
  1.  
  2. <HTML>
  3.  
  4. <head>
  5. <title>Concat two strings</title>
  6.  
  7. </head>
  8.  
  9. <form name="demo">
  10.  
  11. <P>Input1: <input type="text" name="inP1" size=40></p>
  12.  
  13. <P>Input2: <input type="text" name="inP2" size=40></p>
  14.  
  15.  
  16.  
  17. <p>
  18. <input type="button" name="button2" value="Concatinate Strings" onclick="document.answer.out.value = document.demo.inP1.value + document.demo.inP2.value">
  19. </p>
  20. </form>
  21.  
  22. <form name="answer">
  23.  
  24. <p>Output: <input type="text" name="out" size=40></p>
  25. </form>
  26. </BODY>
  27. </HTML>
Reputation Points: 12
Solved Threads: 4
Newbie Poster
Larry_b is offline Offline
16 posts
since Jan 2010
Jan 31st, 2010
0
Re: populating second drop down list box based on the selection of the first
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nlal is offline Offline
23 posts
since Jan 2010
Feb 1st, 2010
0
Re: populating second drop down list box based on the selection of the first
Hi,

I think I have something. I think what you want is a self-posting page.
The follow example kind of does close to what you want.

Get rid of the arrays and use the MySQL commands and I think you will have something you can use.

I hope this helps.

Here is that code:

PHP Syntax (Toggle Plain Text)
  1.  
  2. <html>
  3. <head>
  4. </head>
  5. <body>
  6. <?php
  7. $key = $_GET['$key'];
  8. ?>
  9.  
  10. <p>Input animal type:</p>
  11. <form id="form1" action="<?php echo $_SERVER['PHP-SELF'] ?> " method="get">
  12. <p>Input1: <input type="text" name="key" size=40></p>
  13. <p><input type="submit" value="Submit" size=40></p>
  14. </form>
  15.  
  16. <?php
  17. $key = $_GET['key'];
  18. if (!is_null($key)) {
  19.  
  20. $row[0] = "Cow";
  21. $row[1] = "Deer";
  22. $row[2] = "Fox";
  23. $row[3] = "Cat";
  24.  
  25. //$result = mysql_query("SELECT * FROM animal_record WHERE Key='$key'");
  26.  
  27. $i = 0;
  28.  
  29. echo "<p>Results:</p>";
  30.  
  31. echo "<form>";
  32. echo "<select name='category'>";
  33.  
  34. //while($row = mysql_fetch_row($result))
  35.  
  36. while($i < 4){
  37. echo "<option>$row[$i]</option>";
  38. $i += 1;
  39. } /* End while */
  40. echo "</select>";
  41. echo "</form>";
  42.  
  43. } /* End if */
  44. ?>
  45. </form>
  46. </body>
  47. </html>
Reputation Points: 12
Solved Threads: 4
Newbie Poster
Larry_b is offline Offline
16 posts
since Jan 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: checkdnsrr
Next Thread in PHP Forum Timeline: PHP or ASP.NET





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC