Refresh + Combo Box

Reply

Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster

Refresh + Combo Box

 
0
  #1
May 8th, 2008
Pretty simple, just dont know how to find the solution XS.

I have a combo box, that once u select the required attribute (A, B, C).

It should display the apporiate text of A, B, C below it.

So any ideas?

Thanks, Regards X
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 28
Reputation: almualim is an unknown quantity at this point 
Solved Threads: 0
almualim almualim is offline Offline
Light Poster

Re: Refresh + Combo Box

 
0
  #2
May 8th, 2008
you can using this:
$_POST['dropdown list name'];
if this not true please give me more explains.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Refresh + Combo Box

 
1
  #3
May 8th, 2008
I said it in the other thread, have an onchange event to submit the page when you select a value from the dropdown list. When the page is submitted, you can know which option was selected from the dropdown list. ($val = $_POST['dropdownlistname']; ) Then query the table with this value as condition and retrieve the data.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster

Re: Refresh + Combo Box

 
0
  #4
May 8th, 2008
Hi nav33n, my php GURU!

  1. <?php $con = mysql_connect("localhost","root"); mysql_select_db("test"); $query = "select col1 from table"; $result = mysql_query($query); echo "<form method='post' action='test.php'>"; echo "<select name=dropdown1 onchange='javascript: document.form.submit();'>"; while($row = mysql_fetch_array($result)) { $value = $row['col1']; echo "<option value='".$value."'>$value</option>"; } echo "</select>"; $firstdropdownlistvalue = $_POST['dropdown1']; $query2 = "select * from table where col2 = '$firstdropdownlistvalue'"; $result2 = mysql_query($query2); echo "<select name=dropdown2>"; while($row2 = mysql_fetch_array($result2)) { $value2 = $row2['col1']; echo "<option value='".$value2."'>$value2</option>"; } echo "</select>"; echo "</form>";?><?php
  2. $con = mysql_connect("localhost","root");
  3. mysql_select_db("test");
  4. $query = "select col1 from table";
  5. $result = mysql_query($query);
  6. echo "<form method='post' action='test.php'>";
  7. echo "<select name=dropdown1 onchange='javascript<b></b>: document.form.submit();'>";
  8. while($row = mysql_fetch_array($result)) {
  9. $value = $row['col1'];
  10. echo "<option value='".$value."'>$value</option>";
  11. }
  12. echo "</select>";
  13.  
  14. $firstdropdownlistvalue = $_POST['dropdown1'];
  15. $query2 = "select * from table where col2 = '$firstdropdownlistvalue'";
  16. $result2 = mysql_query($query2);
  17. echo "<select name=dropdown2>";
  18. while($row2 = mysql_fetch_array($result2)) {
  19. $value2 = $row2['col1'];
  20. echo "<option value='".$value2."'>$value2</option>";
  21. }
  22. echo "</select>";
  23. echo "</form>";
  24. ?>

From your other thread a few questions, as mine is linked to a mysql database which the values are retrieved from that.

I have pretty much everything you have there already minus the on change even like you said.

  1. echo "<select name=dropdown1 onchange='javascript: document.form.submit();'>";

So this is the only code I need to add to let my form submit itself and show the appropriate data?

Also another quick Q, once I have selected the drop down item and refreshed the page, I wish to keep the selected item in the combo box and not be reset to the intial value.Any ideas?

Thanks for all your help again, ill try that now. - I just tested it and it works BUT my first drop down isnt refreshing but my second is =S (Ill go debug and keep you posted)

Regards, X
Last edited by OmniX; May 8th, 2008 at 9:31 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster

Re: Refresh + Combo Box

 
0
  #5
May 8th, 2008
After a whole bunch of debugging everything is done!
Thanks nav once again your a legend
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Refresh + Combo Box

 
0
  #6
May 9th, 2008
lol.. no ! I am a learner.. I am glad your problem was fixed !
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC